The success of a hash-table implementation of the ADT table is related to the choice ol a good hash function. A good hash function is one that is easy to compute and that will evenly distribute the possible data. Comment on the appropriateness of the following hash functions. What patterns would hash to the same location?
a. The hash table has size 2,048. The search keys are English words. The hash function is
h(liey) = (sum of positions in alphabet of key's letters) mod 2048
A red-black tree for Exercise 10
b. The hash table lias size 2,048. The keys are strings that begin with a letter. The hash function is
b(key) = (position in alphabet of first letter of key) mod 2048
Thus, “BUT” maps to 2. How appropriate is this hash function if the strings are random? What if the strings are English words?
c. The hash table is 10,000 entries long. The search keys are integers in the range 0 through 9999. The hash function is
h{ key) = (key * random) truncated to an integer
where random represents a sophisticated random-number generator that returns a real value between 0 and 1.
d. The hash table is 10,000 entries long {hashjtable_size is 10000). The search keys are integers in the range 0 through 9999. The hash function is given by the following Java method:
public int hashlndex(int x) {
for (int i = 1; i = 1000000; ++i) {
X = (X * x) % HASH_TABLE_SIZE;
} // end for
return x;
} // end hashlndex
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.