The java API: java.sun.com/j2se/1.3/docs/api/

Lab 9: Testing Hashing Functions

In this lab you will test empirically five different hashing functions and calculate the number of collisions for set of keys.

To do that, write a java program that implements five hashing functions (any functions you want) that will be used to hash 800 randomly generated keys to hash tables of size 997.

The keys should be integers of at most 6 digits. The hash table will only be used to keep track of the number of keys hashed to each address (No storage for the keys).

At the end, calculate the total number of collisions in each table (for each function) and output these values.

If you still have time, play a little with your functions: try different parameters to see if you can improve performance (decrease number of collisions).

 > java testHashingFunctions
--------------------------------------------------------------------------------

Number of Collisions for F1 = 241
Number of Collisions for F2 = 245
Number of Collisions for F3 = 400
Number of Collisions for F4 = 551
Number of Collisions for F5 = 288
--------------------------------------------------------------------------------