Question: JAVA Write a program that uses a binary search tree to find out how many times each word in a writing sample occurs. Your program
JAVA
Write a program that uses a binary search tree to find out how many times each word in a writing sample occurs. Your program should do the following:
Read a text file.
Build a binary search tree that uses data from the text file as it is read in:
If the next word isnt in the tree, add it to the tree
if the next word is in the tree, increment its count
Print a word frequency histogram
EXAMPLE
Input: This sentence repeats words because a sentence that repeats words makes a good example sentence.
Output: a 2
because 1 example 1
good 1
makes 1
repeats 2
sentence 3
that 1
this 1
words 2
PLEASE LABEL WEEK 1 - 2 IN ANSWER
Week 1
Create a tree class.
Give your tree class the necessary private properties for a binary tree.
Create at least 1 constructor.
Create public methods to get/set all your private data fields.
Implement methods required for a binary search tree.
In your main method, thoroughly tests/demonstrate the methods from your tree that youve implemented
Week 2
Add code that will allow you to read in a file. I recommend using the scanner class. You can find the documentation here: http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Scanner.html
For each word of your file, do one of the following:
If that word already exists, increment a counter for that word by 1.
If that word doesnt exist, insert it as a new node in the tree.
Print the word histogram.
Show the text file youll be reading in your screencast and submit it along with your code.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
