Question
Alter the following class Hash.java to create a hash table with the following criteria. No compression function is needed: Consider the list of english words
Alter the following class Hash.java to create a hash table with the following criteria. No compression function is needed:
Consider the list of english words available at: https://raw.githubusercontent.com/bitcoin/bips/master/bip-0039/english.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. For example, assume your list has 5 words: the, one, little, pig, is; and the values for the hash code are 1, 1, 1, 2, 2; then you have 2 collisions (2 distinct values) and the highest number of collisions for a single word is 3.
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
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
In the first part, the hash code is investigated using a polynomial hash code. Let a word with k characters by written as xo X1. Xk-1 e.g. "act" would have xo: "a", x,-"c", and x2="t". The polyno mial hash code formula is h(s) = x0ak-1 + Xiak2 + +Xk-2a + 4-1. In the first part, the hash code is investigated using a polynomial hash code. Let a word with k characters by written as xo X1. Xk-1 e.g. "act" would have xo: "a", x,-"c", and x2="t". The polyno mial hash code formula is h(s) = x0ak-1 + Xiak2 + +Xk-2a + 4-1Step 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