[MSOE Homepage]

Dr. Taylor's MSOE Homepage

Unix is a Four
Letter Word

My Photo Album

My Personal Homepage

CS-285 Main page

CS-285 -- Lab 5: Hash Table

Winter Quarter 1999-2000



Electrical Engineering and Computer Science Department
Dr. Christopher C. Taylor

CC-27C, 277-7339

www.msoe.edu/~taylor/

Purpose

The purpose of this lab assignment is to develop a better understanding of hash tables. This is accomplished by writing a hash table class and experimenting with different hash functions on the dictionary file data used in lab 1.

Assignment

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 file (dict.txt) used in lab 1 and lab 4. 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 lab 6.

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

The lab report should be self-contained. That is, it should be possible for someone to understand what you did and why without seeing anything other than your report. Your report should include:

  • Purpose
  • Problem Statement
  • Procedure -- (what approach you used to solve the problem, how you picked your hash functions and hash table sizes, etc...)
  • Documented source code.
  • Discussion (results from your experiments (and 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 summary of your activity log indicating how much time you spent on each phase of the assignment. 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
  • Conclusions (what you learned, suggestions of how the lab could have been better, things you would have done differently, other hash function ideas, etc...)

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.

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

If you have any questions, consult the instructor.


This page was created by Dr. Christopher C. Taylor, copyright 1999-2000.