Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

All I need is the test class for this, with the main method that can read text files and make an index. This assignment is

All I need is the test class for this, with the main method that can read text files and make an index.

image text in transcribedimage text in transcribed

This assignment is end of chapter 6, Programming Project 7, from page 357 of the textbook. I am simply giving you more specific details Define an IndexTree class such that each node has data fields to store a word, the count of occurrences of that word in a document file, and the line number for each occurrence. Use an ArrayList to store the line numbers. Use an IndexTree object to store an index of words appearing in a text file, and then display the index by performing an inorder traversal of the tree BinarySearchTree E extends Comparable> IndexTree + E find(E target) +boolean contains(E target) + boolean add(E target) + void printOrderedData0 BinarySearchTree index +IndexTree(String filename) + void addRecord(String w, int line) + void printIndex0) Word Kinterface>> Comparable - String w -int count ArrayList Integer> lines int compareTo(Word o) + Word(String w, int line) + void addOccurrence(int line) + String toString) Consider the UML above. I left a few things out of the UML that you won't need to directly worry about (e.g the BinarySearchTree class extends the BinaryTree class, which I've provided you with) Do the following Implement the find method of the BinarySearchTree class. The rest of that class is already implemented (from an in-class example). Carefully read the javadoc comment that I provided in the source code to make sure you implement the correct thing Implement the IndexTree class, along with its inner class Word, as specified in the UML above. A reminder on some UML notation: means private, and+ means public. Here are details of what the various methods should do: Inner class, Word, represents one unique word, the count of the number of occurrences of that word, and a list of all of the line numbers from the file where it appeared. o Constructor initializes the Word for the first occurrence found, so should initialize the field w to whatever String the word is, count to 1, and the ArrayList to a single element consisting of whatever line number was specified addOccurrence should add the specified line number to the ArrayList only if it's not already in the list, and regardless should increase count by 1. We want to know total number of times the word was found, but the list of line numbers should only have unique line numbers (think of a book's index, where you wouldn't see the same page number listed multiple times for the same word)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago