Program 7 CECS 275
Essentially the same problem as in Program 5 – read a file of words and count the occurrences of word and then print the words in alphabetic order with their count.
The main difference for this assignment is the data structure used to store and count the words must be a binary tree. The tree must be in a class called WordTree. The WordTree class must provide operations to perform the following:
- A constructor to initialize the tree
- A recursive size operation – private
- A recursive depth operation – private
- An recursive insert operation that insert new nodes in the tree in order (sorted ascending) and, if the word is already in the tree, increases the word’s count by 1 – private
- A recursive in order output operation that prints the words in alphabetical order with their counts – private
- A “new node” helper operation that creates and returns (through the function call) a new node when one is needed for insertion into the tree – private
- For all but the constructor and #6, public versions of operations 2 – 5 that are not recursive to be called from main (or wherever)
You can easily adapt the struct (or class) you made for words in Program 5 to this program.
STL classes are not permitted. You must code the tree operations.
Turn in all source code to the drop box for Program 7 on BB.