Question: In this assignment, your task is to create a class called Wordlist that counts how many times each word appears in a file. The class
In this assignment, your task is to create a class called Wordlist that counts how many times each word appears in
a file. The class must use an AVL tree as its underlying representation vectors, arrays, or other container data
structures are not allowed. The data in the tree should be sorted by word using the standard C comparison
operators. Note that the Wordlist class is an AVL tree you should not be implementing the Wordlist class and a
separate AVL tree class.
When it's done, you'll be able to write code like this:
Which prints:
Number of different words:
Total number of words:
Most frequent word: the
Number of singletons:
Files
WordList.h darr an incomplete. h file for your project
Wordlist.cpp darr an incomplete cpp file for your project
small.txt darr a small test file you can use for testing
smallout.txt darr the result of running the Wordlist printWords method on small.txt
tiny shakespeare.txt darr a larger text file you can use for testing
tiny shakespeare out.txt darr the result of running the Wordlist printWords method on tinyshakespeare.txt
Public Methods
Methods must preserve the AVL balance and binary search tree properties.
default constructor creates an empty Wordlist whose root is a null pointer
file constructor a constructor that takes the name of a file as a string as input, and adds all the words in that
file to the Wordlist object as described under insert.
copy constructor a constructor that creates a deep copy of its constant Wordlist reference parameter.
operator overloads the assignment operator for Wordlist objects to make a deep copy of its constant
Wordlist reference parameter and return a reference to the calling object. The operator should behave
correctly under self assignment.Public Methods Methods must preserve the AVL balance and binary search tree properties. default constructor creates an empty Wordlist whose root is a null pointer file constructor a constructor that takes the name of a file as a string as input, and adds all the words in that file to the Wordlist object as described under insert. copy constructor a constructor that creates a deep copy of its constant Wordlist reference parameter. operator overloads the assignment operator for Wordlist objects to make a deep copy of its constant Wordlist reference parameter and return a reference to the calling object. The operator should behave correctly under self assignment. destructor deletes dynamic memory allocated by the tree. insert if the Wordlist does not contain the method's string parameter, it inserts the string into the Wordlist with a count of one; if the Wordlist does
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
