Answered step by step
Verified Expert Solution
Question
1 Approved Answer
this is IndexNode.java this is IndexTree.java this is ReadingFromFileExample.java this is txt example 1 Your Assignment We will create an IndexTree, a special type of
this is IndexNode.java
this is IndexTree.java
this is ReadingFromFileExample.java
this is txt example
1 Your Assignment We will create an IndexTree, a special type of Binary Search Tree. The IndexTree does a bit more than your standard tree, as we will use it to build an index of a file. This will be much like the index you find at the end of a textbook, where each topic is listed in alphabetical order with the pages it is found on. Since files don't have traditional pages to work off of, we will instead use line numbers. Furthermore, rather than building an index of only a few select topics, we will build an index over all the words in the file. To do this, we use a special type of node. The IndexTree is made up of special IndexNodes. Rather than using generics, each IndexNode stores a word, the count of occurrences of that word, and a list of all lines that word appeared on (this means that each IndexNode will hold their own list). Nodes in the tree will be sorted by the String. Use an IndexTree object to store an index of all the words that are in the provided text file, then display the index by performing an inorder traversal of the tree. 2 How to Read a File Good news, everyone! You already know how to do most of it. I've attached a file showing how to use Scanner to read every line of text from the file, split that line into individual words, and print out each word. Be sure to scrub each word of those pesky punctuations, like commas package index; import java.util.List; public class IndexNode { // The word for this entry String word; // The number of occurrences for this word int occurences; // A list of line numbers for this word. ListStep 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