CS285 -- Lab 5: Hash Tables



->Courses
->CS285
-->Homework
-->Quiz 1
-->Lab 1
-->Lab 2
-->Lab 3
-->Lab 4
->Lab 5
-->Lab 6
->Electronic Submission
->MSVC Info
->STL Help
->Book Errata
->Tentative Schedule
->Course Policies

[Courses]
[Rich][Home][Rich]
[Author]

Fall Quarter 2000

Overview

In this lab, you should develop a better understanding of hash tables. You should accomplish this by writing a hash table class and experimenting with different hash functions on the dictionary file data used in the previous lab.

Procedures

The first step is to write a templated hash table class that can vary in the type of data hashed, the number of buckets, and the hash function used. The hash table class should have member functions that will do the following:

  • Add objects to the hash table.
  • Check to see if an object is already in the hash table.
  • Count the number of empty buckets in the hash table.
  • Count the number of collisions represented in a given instance of the hash table. (E.g., if there are currently 12 empty buckets, 6 buckets with one object, and 3 buckets with two objects in them, your function should return 3 (for the three collisions that occurred when the second object was added to each of the buckets with two objects in them)).

The next step involves choosing an appropriate hash function and table size for the words in the dictionary used in the previous lab. You should implement at least four different hashing functions (select from the ones discussed in class or select your own). Experiment with the different hashing functions on hash tables of varying size. You may find it useful develop your own metric for rating each hash table configuration. Based on your experimentation you should select one of the hash functions and a particular hash table size to use as your container for the dictionary for the next lab.

Lab report (due 11:00pm, the day prior to week 9 lab)

Your report should include:

  • Your design documentation.
  • The Documented source code for your program.
    You may find it useful to use the code.bat and dump.bat batch files to produce one file containing all of your source code with the markup commands required by my electronic submission process.
  • A discussion of the results from your experiments (including a discussion of their meaning), reasons for your selection of a hash table size and hash function for next week, major problems discovered with some of your hash function choices, etc...)
  • A brief description of any problems you encountered or questions you have regarding the lab.
  • A discussion of what each team member accomplished.
  • A summary of your activity log indicating how much time you spent on the assignment. In addition to the total time spent on the project, please report the time in the following categories:
    • Design
    • Coding
    • Debug (before you think it's working)
    • Test (after you think it's working)
    • Documentation
    • Other
  • Any suggestions you have for how the lab could be improved.

IMPORTANT NOTE: Be sure to save your program for future use. We will be using this assignment in next week's lab assignment.

As with any report you submit, correct spelling and grammar are required. In addition, your report should be submitted electronically following the Electronic submission guidelines. (You may wish to consult the sample report before submitting your report.) Be sure to keep copies of all your files, in case something gets lost. It may be wise to keep a diskette backup as well.

Your grade will depend on quality of design, clarity of code and documentation, as well as whether your program produces the correct results. If you have any questions, consult your instructor.

Office: CC-27C, Phone: 277-7339
Last Updated: August 14, 2000
© 2000 Dr. Christopher C. Taylor