Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A text file will be provided for the database of English words, their type (noun

ID: 3589010 • Letter: A

Question

A text file will be provided for the database of English words, their type (noun, verb, etc.) and their meaning. Create an efficient hash function to convert each word into an int Key. JAVA

Sample from dictionary.txt :

's_gravenhage|NOUN|the site of the royal residence and the de facto capital in the western part of the Netherlands; seat of the International Court of Justice
.22|NOUN|a .22 caliber firearm (pistol or rifle)
0|NOUN|a mathematical element that when added to another number yields the same number
1|NOUN|the smallest whole number or a numeral representing this number; "he has the one but will need a two and three to go with it"; "they had lunch at one"
1-dodecanol|NOUN|a colorless insoluble solid alcohol used to make detergents and pharmaceuticals
1-hitter|NOUN|a game in which a pitcher allows the opposing team only one hit
10|NOUN|the cardinal number that is the sum of nine and one; the base of the decimal system
100|NOUN|ten 10s
1000|NOUN|the cardinal number that is the product of 10 and 100
10000|NOUN|the cardinal number that is the product of ten and one thousand
100000|NOUN|the cardinal number that is the fifth power of ten
1000000|NOUN|the number that is represented as a one followed by 6 zeros

Explanation / Answer

We need to create a hash function to minimise the collision. If we some unicode of all char in string then "bus" and "usb" will have same hash or if we choose initial m char then it is not going to work as in work ans worker then if we take initial 4 char then they have same hash.

For more better the hash taker char values and multiply it with prime number.

better hash function:

will going more unique hash values.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote