Question
The purpose of the assignment is to perform a comparative analysis of several hash functions. Part 1: Create a HashMap using the polynomial hash code
The purpose of the assignment is to perform a comparative analysis of several hash functions.
Part 1:
Create a HashMap using the polynomial hash code formula: Using the list of 466,544 English words from: https://raw.githubusercontent.com/dwyl/english-words/master/words.txt
For each word, compute the hash code for a = 10, 33, 37, 39 and 41. Record the number of collisions and the highest number of collisions for a word.
Part 2:
In the second part, the MAD compression function is investigated: Use the same list of words, and apply the polynomial hash code with a = 41 to obtain an integer. Then compute the values using the MAD compression function with N = 426,000 (This specific value of N ensures an 80% load)); p=426,007; =10,000, 100,000, and 200,000; and =50,000, and 150,000. Compute the number of collisions and highest number of collisions for the resulting 6 algorithms.
Hash.java:
public class Hash{ | |
int n; | |
//Provided for comparison only; feel free not to use | |
long hashJava(String s) { | |
return s.hashCode(); | |
} | |
long hashPolynomial(String s) { | |
return s.hashCode();//TO DO MODIFY TO ANSWER THE LAB QUESTION | |
} | |
long compressionMAD(long i) { | |
return i % n;//TO DO MODIFY TO ANSWER THE LAB QUESTION | |
} | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
} | |
} |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started