Docsity

Comparing Hashing Functions: Modulo, Multiplicative, and Pearson's Method, Assignments of Computer Science

Toggle sidebar
bg1
Programming details for Question 4 of Assignment #3 (9/28/2002):
Question: Create a computing experiment to compare the hashing functions given in the book –
the modulo method and the multiplicative method – to Pearson's method. An implementation of
Pearson's method can be found at
http://mail-index.netbsd.org/tech-perform/2001/11/27/0009.html.
(1) Use the following tables and constants:
NUM_SLOTS = 251 (the largest prime less than 256) //how many slots to hash on
int wordsHashedToSlot[NUM_SLOTS] //store times a word hashed to a particular hash value
int randomNumberTable[256] //table for Pearson's hash
(2) Use the following two input files:
The file “hashing_text.txt” (posted here) contains words separated by whitespace
characters (blank, tab, or end-of-line), taken from the UCF website
The file "rand_num.txt" (posted here) contains the (pseudo) random number table that
Pearson suggested would work well with Pearson's hash
(3) Perform the following tasks:
Initialize randomNumberTable to the values in file "rand_num.txt"
For each hashing function
initialize wordsHashedToSlot to all zeros
for each word in the input file “hashing_text.txt”
set valueToIncrement to the result of the hashing function on the current word
increment wordsHashedForSlots[( valueToIncrement modulo NUM_SLOTS)]
Analyze the results in wordsHashedForSlot using the chi-squared test mentioned in
the first assignment
After running this program, the students should report which hashing function seemed to work
the best based on the computed chi-squared test values.

Partial preview of the text

Download Comparing Hashing Functions: Modulo, Multiplicative, and Pearson's Method and more Assignments Computer Science in PDF only on Docsity!

Programming details for Question 4 of Assignment #3 (9/28/2002): Question: Create a computing experiment to compare the hashing functions given in the book – the modulo method and the multiplicative method – to Pearson's method. An implementation of Pearson's method can be found at http://mail-index.netbsd.org/tech-perform/2001/11/27/0009.html. (1) Use the following tables and constants: NUM_SLOTS = 251 (the largest prime less than 256) //how many slots to hash on int wordsHashedToSlot[NUM_SLOTS] //store times a word hashed to a particular hash value int randomNumberTable[256] //table for Pearson's hash (2) Use the following two input files:  The file “hashing_text.txt” (posted here) contains words separated by whitespace characters (blank, tab, or end-of-line), taken from the UCF website  The file "rand_num.txt" (posted here) contains the (pseudo) random number table that Pearson suggested would work well with Pearson's hash (3) Perform the following tasks: Initialize randomNumberTable to the values in file "rand_num.txt" For each hashing function  initialize wordsHashedToSlot to all zeros  for each word in the input file “hashing_text.txt”  set valueToIncrement to the result of the hashing function on the current word  increment wordsHashedForSlots[( valueToIncrement modulo NUM_SLOTS)]  Analyze the results in wordsHashedForSlot using the chi-squared test mentioned in the first assignment After running this program, the students should report which hashing function seemed to work the best based on the computed chi-squared test values.