CS2851 -- Lab 6: Hashing Collision Analysis

Outcomes Addressed

  • understand and apply complex data structures and algorithms.
  • have a thorough understanding of commonly used library data structures.

This assignment should be done individually

Procedure

Your program should generate all of the results for the following table:

Method # of collisions # of empty buckets Maximum # of elements in a bucket
HC1 with 100,000,000 size table   
HC1 with 1,000,000 size table   
HC1 with 10,000 size table   
HC2 with 100,000,000 size table   
HC2 with 1,000,000 size table   
HC2 with 10,000 size table   
HC3 with 100,000,000 size table   
HC3 with 1,000,000 size table   
HC3 with 10,000 size table   
HC4 with 100,000,000 size table   
HC4 with 1,000,000 size table   
HC4 with 10,000 size table   

Where HC? represent the following hashCode implementations:

  • HC1: The String classes built in implementation
  • HC2: The length of the string
  • HC3: The sum of the ASCII values of the first, middle, and last characters in the string
  • HC4: ((((word[0]-'a')<<5 + word[1]-'a')<<5 + word[2]-'a')<<5 + ... + word[word.length()-1]-'a')

You should use the words.txt file as your input data set when generating the above table.

Relevant tidbit

You will not be able to use the HashSet to do your tests. You should use either an array or an ArrayList instead.

String.hashCode Overwriting

Create three new classes that contain a String as a field and override the hashCode() method.

Deliverable (11pm Thursday of week 10)

You should submit the completed table and a brief (1-2 paragraphs) discussion on which ranks the four hash code methods and identifies an optimal table size for each. Are any of the hash code methods clearly superior or inferior to the others?

Your submission may either be in the form of an email message or hardcopy. It should include your documented source code as an attachment.

If you have any questions, consult your instructor.

Acknowledgment

This assignment was originally developed by Dr. Chris Taylor.

  • © 2001-2009 Dr. Christopher C. Taylor •
  • Office: L-343 •
  • Phone: 277-7339 •
  • npǝ˙ǝosɯ@ɹolʎɐʇ