SymbolTable that reprsents a symbol table -- a hash table that stores associations between symbols and values (typically representing machine locations rather than run-time values). Use separate chaining to handle collisions. For this assignment you may represent symbols by strings and values by integers.
Also, define a class SymbolTableEntry to store the symbol/value pairs. This is to have its own toString method. Ideally it will implement the Comparable interface to facilitate the sorting described below.
You may define any other additional classes you find helpful. You will need to define one or more additional classes to get the extra credit.
Your SymbolTable class should have methods insert, search, traverse, and sort. It should have a constructor that takes two arguments -- one giving the table size and one giving the integer value that is to be returned in the case of unsuccessful search.
Insertion of symbols that are already in the table should not be allowed (you needn't print an error message or throw an exception in this case). The traverse method is to print a textual representation of each table location in order, together with the symbols at that location and their values. The sort method is to return a Vector containing a list of SymbolTableEntrys, in lexicographical order of the symbols. You needn't do fancy formatting for either of these methods. Since hash tables don't support especially efficient sorting algorithms, you may use any general purpose sorting method for sort.
The SymbolTable class should also have methods successfulSearchTime and unsuccessfulSearchTime that return the expected number of element comparisons required for successful and unsuccessful search respectively. These values should be the exact values for the given symbol table, rather than the estimates given in the textbook. Like the textbook, you should assume that all symbols are equally likely to be sought in the successful case, and all table locations are equally likely to be searched in the unsuccessful case.
Finally, SymbolTable class should have a method draw that creates a simple graphic representation of the table. All it needs to provide is the index of each hash table location, and a graphic indication of how many pairs are stored in that location. To get the extra credit, you must use the graphics provided in Java (i.e., frames and panels). Otherwise, you may use characters and text.
For the hash function to be applied to symbols, use the hash function provided by Java, reduced modulo the table size.