Write a word frequency program (FrequencyST.java) that reads from System.in.
Use a 3 state machine to separate the words as discussed in class.
Count the words by inserting objects containing a word and a count into a binary search tree. The class of the objects must implement Comparable and the comparison should be based just on the word.
Print the results ordered first by count (decreasing order) and then by word (increasing order). To do this, insert the words and counts into a second binary search tree containing (Comparable) objects with words and counts, but with compareTo and equals methods that do lexicographic order in a way that gives the desired output order. You can then use the iterator to traverse the tree and print the words.
- Repeat the first part, but for the counting phase, use a hash table rather than a binary search tree. The printing phase will be the same as in the first part. Call this program FrequencyHT.java.