Homework 4
Linked Lists and Binary Search Trees


Due Date: Monday, Jan 31
Point Value: 100 points 

Overview and Specifications

In this homework assignment, you will create a LinkedList class and a Tree class both of which implement a List interface. The classes will be used by a Keyword program that displays an ordered list of how many times each Java keyword (reserved word) appears in a Java source file(.java file).

The Keyword program takes two arguments on the command line, a switch (-l for linked list and -t for binary search tree) and the name of a Java source file. It then reads the file, keeping track of the number of occurrences of each keyword appearing in the Java file in the given type of data structure, and then outputs the list. The keywords should be inserted into the data structure the first time they occur in the file (no fair putting all the Java keywords into the data structure to begin with:).

For example:

java Keyword -l Test.java  (uses ordered link list)
 
 1 class
 2 do
 5 if
 2 while

java Keyword -t Test.java  (uses binary search tree)
 
 1 class
 2 do
 5 if
 2 while

java Keyword Test.java

usage: java Keyword -[lt] filename

You may assume the keywords are delimited with white-space (and ignore any that aren't, if you like).

Please email me the following 6 files:

on or before Monday, January 31.