Bill Teter
Office:          149 Redcay
Telephone:    2782
Office Hours:  Tuesday, Thursday 9:00-12:00

email:  william.teter@plattsburgh.edu

       

 

Lab 13  Sets and permutations and a dynamic linked sorted list

In this lab you will do two projects.  The first is to write a program called Anagram which has a single command line argument.  The argument will be a string.  Your program will print all the permutations of that string that are English words found in the file /usr/share/dict/words.  My public directory,
    /home/teterwa/public/csc223/lab13
 contains a Permuations class and a Test class for it.  You can use my Permutations class or write your own.

The Anagram program should read in the words file into a HashSet.  Use the HashSet constructor that allows you to set the initial size so that the underlying array is not more than 75% full.  Notice that if the command line argument string contains multiple letters then each anagram for that string appears twice in the output.  For example the anagrams of "that"  will print "that" twice because of the two t's.  Improve the Permutations class by having its iterator avoid duplicates by using a set instead of a list. 

The second project involves a dynamic linked sorted list.  Call the class SortedLinkedList, make the class generic on a Comparable type and implement the following methods:

public int size()

public boolean add(AT x)
    // always returns true.

public AT get(int i)
    //pre:  0 <= i < size()
    // returns the i'th object on the sorted list.

I have a test program in my public directory for testing your SortedLinkedList class called TestStrings.java.