CSC220 Lab Number 8
Due: 11:59PM, Tuesday, November 10
The goal of this lab is to develop a code that reads a user-specified text file and
does the following:
-
for each word that over English alphabet that appears in the text file,
stores the word in lower case and the line numbers of its occurrences, and then
-
outputs the list of words and their occurrences.
To do this, we will use a binary search tree whose nodes are
objects from class WordPos,
where WordPos is a class that implements Comparable and consists of
a String object that stores the word
and a LinkedList object that stores the locations.
Your tasks are the following:
-
Fill in missing parts in the BinarySearchTree class.
-
Write the code for the word occurrence recording.
Download the following files:
Below is the list of things to do:
-
In BinarySearchTree.java, implement remove and contains method.
-
In WordPos.java, implement iterator(), listIterator(), compareTo(), and add().
-
Write a class that reads a text file, saves the information (word and location) in a tree of WordPos objects, and then outputs the result.
In writing the code, note that an input text may have characters other than English alphabet.
Such characters include punctuation and numerics.
A sample program is here.