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:

Alter the following class Hash.java to create a hash table with the

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-1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!