Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

COMPARE the three types of organization-wide incentive plans.

Answered: 1 week ago

Question

9. Mohawk Industries Inc.

Answered: 1 week ago