Question: This program will practice working with binary search trees. Use the provided TreeNode.java and BinarySearchTree.java files. The BinarySearchTree class offers basic operations of searching, insertion
This program will practice working with binary search trees. Use the provided TreeNode.java and BinarySearchTree.java files. The BinarySearchTree class offers basic operations of searching, insertion and removal.
BinarySearchTree:
Add public method getNearby which is passed a word and returns a list of nearby values, including the parent word and any sibling. This method could be called by the user when a word is not found to get suggestions of nearby words. One method inserts the new word and then searches for it keeping track of previous and then removes it when done.
Main algorithm:
Use text file words.txt and build the binary search tree. Report its length.
Allow the user to enter words until sentinel "quit".
Clean the word by removing any leading or trailing blanks and convert to lower case.
Seach for the word in the binary search tree
If found:
Report it is found
Else:
Call getNearby to report its neighbors
Ask user to enter choice from nearby list or none
If user enters none:
Add the word to the binary search tree
Report the new length of the binary search tree
Sample Output:Grading Rubric:The program is not accepted if it does not compile. Infinite loops while true or use of break, continue or other goto statements is not accepted.
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
