Question
Write a command line application Problem2.java that indexes the words contained in a text file. Your program should go through the input file line by
Write a command line application Problem2.java that indexes the words contained in a text file. Your program should go through the input file line by line. For each line, it extracts each word, and insert that word, along with it's line numberinto an AVL tree. Each element of the AVL tree should contain a unique word and a linked list of line numbers where that word occurs.
Write the method public void indexWord(String word, int line) that adds an occurrence of the word word in line line. If a word already exists in the AVL Tree, simply add the new line number to the existing node. If a word appears on the same line twice, it should only have one entry in the list for that line.
Write the method public List getLinesForWord(String word) that looks up a word and returns a list of lines in which it occurs.
Write the method public void printIndex() the prints out each unique word that is stored in the Avl tree along with a list of line numbers in which that word appears.
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