Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Data Structure Expert

In this assignment, you are to write a program that analyzes a selection of text, counting the number of times each word appears in the text.   Your word counts must ignore capitalization, so  the, The, THE, and tHe all increase the count for the word "the" by one.  For purposes of this assignment, a word is any consecutive string of letters and the apostrophe character, so  don't  counts as a single word, and  best-selling counts as two words: best and selling.   Notice that a blank space will not necessarily occur between two words.   Numbers such as 27 and 2/3 will NOT be counted as words.
 
You must store the words and the counts of the words in a single binary search tree. Each word occurring in the text can only be stored once in the tree.  Call the structure for the nodes of the tree WordNode, and call the references in this structure left and right.  Use Strings to store words in the tree.  Call the class implementing the binary search tree WordTree.  It must contain the following public methods:

-  constructors
-  add:  adds the given word to the tree if it is not already in the tree OR increments the appropriate counter if it is already there.  It returns nothing.
-  countNodes:  returns the number of words currently stored in the tree.
-  countWordsWith4Chars: returns the number of words which have exactly four characters.
-  print: display the words of the tree in alphabetical order, and next to each word, prints the number of times each word occurs in the text.
 
Three of these operations (all but add) must visit every node in the tree.  One of these must use preorder traversal, one must use inorder traversal, and one must use postorder traversal.  You must decide which to use for each method, but use comments to document
the type of traversal used.   
 
The WordTree class may have only one data member variable, root, and it must be private.  
 
Your program should perform the following steps:
 
1.  Prompt the user for the name of the file (a string). Use the string input by the user as an argument to open file:
 
2.   Open the file on disk, and process its contents, adding unique words to the BST and increasing the counts of existing words if necessary
3.  Repeat steps 1&2 until the user enters some sentinel value. 
4.  Print out the total number of nodes in your tree
5.  Print out the number of words which have exactly four characters.
6.  print out the contents of a tree in alphabetical order
 
Optional: if you have time, implement a method to delete every node from your BST that contains a word that is 3 or fewer letters long (note that you must explicitly make these deletions, not fail to insert these words in the first place).

Data Structure, Computer Science

  • Category:- Data Structure
  • Reference No.:- M9894730
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Data Structure

Data Communication Delivering Information anywhere

Topic: Data Communication Delivering Information anywhere. Write a 9-12 pages paper in which you: Present an overview of the origin and history of the concept. Describe the current use of and attitude toward the concept. ...

Problem regarding the management program

Problem: Looks like its just adding a save and load feature to the same file you sent me for python 3.5 Until now, you have had to leave your team management program running on your computer indefinitely since you did no ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As