CS 210 - Lab 9: Registration Revisited
Due May 1, 2001

In lab 7 you checked the courses students wanted against the actual courses. In this lab you'll essentially redo that, and add some extra functionality to the process as well. Here's what you need to do: in the previous lab your data structure was a sorted Vector. You'll need to change the sorted Vectors to Hash Tables of an appropriate size. (Once you've done this, an interesting experiment would be to check the speed of the new program against the speed of what you had previously). In addition, you will add the functionality that independent study courses are not in the course file. An independent study is a course whose number is 291, 292, 293, 294, 401, 402, 403 or 404 (e.g CSCI291 would be an independent study). Students are always assumed to be allowed to enroll for independent studies.

You are to write a Hash Table class for this lab. It must be general (indeed you will use it for another task in the next lab). You should use a linked list or a vector to handle overflow (an example of a linked list hash table is in your book). In addition to get(Object key) and put(Object key, Object value), write methods output, isEmpty, containsKey and statistics. The output method should output the elements of the table (and not any null elements). The isEmpty method should do exactly what you'd expect. The containsKey method should return a boolean when the key is in the table. The statistics method should print the number of buckets used, the number of buckets available, the number of buckets with overflow, and the average length of overflow for those buckets. The constructor of your hash table should take an integer which is the "guess" of how many items will be in the table. The constructor should use the rules of thumb on table size to find an appropriate size. The put method should check to see if the load factor is higher than 90% as a result of the put and if so, the table should be resized and all of the elements should be moved to the appropriate new spots.

Remember, all Java Objects have generic equals(), toString(), and hashCode() methods defined. You can define your own version of these for your classes as needed.

My tolerance for code which doesn't use constants, isn't indented properly, prints out such that much of the code doesn't show up, isn't well commented, etc. is now zero. Consider yourselves warned.

Put the usual stuff in your dropbox and hand in output which demonstrates all of the required functionality (and hand in your code too of course).