Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C + + Task 1 . Binary Tree Class Using the lecture material as a guide create a binary tree class. This class should
In C Task Binary Tree Class
Using the lecture material as a guide create a binary tree class. This class should be generic so that it will operate on any given type.
Your class should have the following functionality:
Binary Tree Functions
Function Description
insert Insert a node into the proper location of the tree
remove Remove a specific node from the tree
contains Report is the tree contains a specific piece of data
findMin Find and return the smallest value in the tree
findMax Find and return the largest value in the tree
isEmpty Determine if the tree is empty
printTree Visit each node in the tree and print the data to the screen.
Task AVL Tree Class
Using the code you created in task as a guide create an AVL tree. If done properly you should be able to use a great deal of functionality from your Binary Tree class and add the code to balance the tree. Your class should balance the tree whenever a node is inserted or removed. This means you will probably have to keep track of when a sub tree is taller and shorter than the other. Feel free to modify the node as needed.
Task The Word Count Class
Create a WordCount class that uses the AVL tree class to count words from a file. The trick here is that you should not have duplicate words in the list. Basically when a word is read from the file the tree should be checked to see if the word already exists in the tree. If it does exists the count for the word should simply be incremented. If it does not exist then the node should be added to the tree and the count for that particular word should be set to You should have functionality that will print each word in the tree and how many times it appears.
Please Note
This is not simply reading a list of words from a file. Your WordCount class should read any text from the file and count the words in it This is going to require a bit of parsing on your part. Please discard punctuation characters like comma and period.
Here is a text file you can use to test your programDownload Here is a text file you can use to test your program
Output
You should output a list of words and the number of times they appear in the file. Here is an example of what the output should look like:
Dorothy
for
is
Please Note: Do not use absolute paths when reading and writing to files. Your should simply use the file name without any path. This is going to require the you put the file in the appropriate file of your project.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started