Question
Write a JAVA Binary Trees program that reads in a body of text, and inserts the text into a binary tree class that you write
Write a JAVA Binary Trees program that reads in a body of text, and inserts the text into a binary tree class that you write from scratch based on alphabetical order.
You should keep an instance count for each word in the text. Each time a duplicate word is added you should be able to update the instance count for that word. At the end of the text insertion you will show statistics for the run.
Firstly, write a program to open the text file and display it verbatim before you start adding it to the tree. A dynamic tree is best suited for this. And include a counter in each tree record to handle duplicate words.
You will download and read in a lengthy text file; Bram Stokers Dracula as text from guttenberg.org http://www.gutenberg.org/ebooks/345.txt.utf-8. If you have problems search for 345 on Gutenberg.org, and select the Plain Text UTF-8 link. As you read the text you will map all words to lower case, and remove all punctuation characters (Only numbers or letters should remain) removed characters should be eaten, NOT replaced with a space. Once the words are pre-processed you will insert them into a binary tree. Do not modify the text file you download, although there are headers and footers from Gutenberg, please leave them intact.
When the binary tree is completely loaded you will perform queries to exhibit the following things:
1) How many times do the following words appear in the text? o transylvania o harker o renfield o vampire o expostulate
2) What is the depth of the tree?
3) How many different words are there in the book? What word is at the root of the tree?
4) What word is at the deepest leaf in the tree? Which word occurs most frequently?
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