CSC 103 Lab Notes Week 5
Hashing Exercises
The following are some exercises that are directly relevant to Assignment 3.
-
Implement HashTable.delete and add some test cases for it into
HashTableTestSimple.java.
Recompile and rerun the tests.
-
Write a program HashTableTest.java that performs HashTable
tests using
InformationRecord
s as the table entries instead of IntEntrys. There's a basic
skeleton
for the program in the examples directory.
-
Modify enter, lookup, and delete to permit entries
with duplicate keys.
-
Figure out what kind of program change(s) would cause HashTable.enter
to throw an
HashIndexInvalid
exception. Make the change(s) and rerun the simple test program to confirm
that the exception is raised.
-
Modify InformationRecord to use name instead of id
as the key. Update HashTableTest to test this new version of
InformationRecord. Note that this change means you need to
reimplement the InformationRecord.hash method along the lines of
Approach 3
discussed in the Week 5 lecture notes. I.e., you can use the code in the
hash3
method in the example Hashing class. (The code for hash3 is in
examples/Hashing.java
).