CSCI 151 - Data Structures and Object-Oriented Development
Spring 2015
Lab 11: Word Counts, part 2: Chained hash tables
- For this lab, we will reimplement the WordCounter interface using
chained hash tables.
- Download the provided code.
- The code for these labs will be incorporated into the editor.wordcount package.
- The code includes the following files:
-
editor.wordcount package
- ChainedHashWordCounter.java: An implementation of WordCounter using a chained hash table.
- This is the only file you will modify.
- Within the file, modify the following methods:
- Implement
get() to perform a retrieval from the hash table. Note that this may involve a linked list traversal. Return 0 if the word is not present.
- Implement
bump() to try to find the word in the hash table. If the word is present, increase its count. If the word is not present, you will need to add it to the hash table. If the load factor of the hash table exceeds MAX_LOAD, you will need to resize the table. (Call getLoad() to check the load factor.)
- Implement
dock() to try to find the word in the table, and decrease its count if it is there. Otherwise, do nothing.
- You may find it helpful to write helper methods to calculate the table entry from the hash code and return the appropriate
WordCounterLink object.
- SortedArrayWordCounterTest.java: Unit tests for ChainedHashWordCounter.java.
- TimeTest.java: Program that compares the running times of different
WordCounter implementations using Moby Dick. This version includes a
test for our hash table implementation, so as to compare it to the others.
- Once your solution is working, run
TimeTest to compare its
performance with the array-based versions from Lab 10.
Grading
For an A+, pass all unit tests. Also, provide the timing information gleaned
from TimeTest via Moodle when submitting. The performance of the hash table
should be drastically superior to that of either array implementation.
Without this, the grade is as follows:
| Number of Unit Tests Passed | Grade |
| 6 | B |
| 4 | C |
| 3 | D |