Open In App

Data Structures | Hash | Question 5

Which of the following hash functions is most likely to cause clustering in a hash table?

(A)



h(k) = k % m

(B)



h(k) = floor(m * (kA mod 1))

(C)

h(k) = k

(D)

h(k) = ((k / m) + k * m) + k % m


Answer: (A)
Explanation:

The modulo operation in option a) results in clustering since the hash values of keys that are close to each other will also be close, leading to collisions. Options B, C, and D use more complex hash functions, which spread out the keys more uniformly across the table..

Quiz of this Question
Please comment below if you find anything wrong in the above post

Article Tags :