Program 7  CECS 275 solution

$25.00

Category:

Description

5/5 - (4 votes)

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:

  1. A constructor to initialize the tree
  2. A recursive size operation – private
  3. A recursive depth operation – private
  4. 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
  5. A recursive in order output operation that prints the words in alphabetical order with their counts – private
  6. 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
  7. 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.