Open In App

Data Structures | Hash | Question 5

Last Updated : 20 May, 2019
Like Article
Like
Save
Share
Report

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads