CS285 -- Lab 5: Hash Tables



->Courses
->CS285
-->Objectives
-->Homework
-->Quiz 1
-->Lab 1
-->Lab 2
-->Lab 3
-->Lab 4
->Lab 5
-->Lab 6
->Electronic Submission
->Old Exams
->C++ Examples
->MSVC Info
->STL Help
->Book Errata
->Software
->Tentative Schedule
->Course Policies

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

Winter 2001-2002

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 three 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. In addition, you should experiment with the hashing function by Bob Jenkins (given here) I have wrapped his hashing function in a function object that is described by JenkinsHash.h and JenkinsHash.cpp. 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:

  • 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 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
  • A discussion of how you worked together as a team.
  • Any suggestions you have for how the lab could be improved.
  • The Documented source code for your program.

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.

© 2001-2002 Dr. Christopher C. Taylor Office: CC-27C Phone: 277-7339 Last Updated: Mon Feb 4 14:31:43 2002
I am responsible for all content posted on these pages; MSOE is welcome to share these opinions but may not want to.