> Consider hash table of size 7 and hash function h(k)=k mod 7. Calculate no of collisions with linear probing for inserti

Consider hash table of size 7 and hash function h(k)=k mod 7. Calculate no of collisions with linear probing for inserti

Posted at: 2014-12-18 
29 36 16 30

a) 2

b) 3

c) 4

d) 5

Ans is c) but i am getting b)....Please explain how answer can be c)

Are you counting secondary collisions on the linear probe? I'm assuming the linear probe is k' = (k+1) mod 7.

Mod 7, those numbers are 1, 1, 2, 2

The 29 is stored at index 1 (no collision).

The 36 is collides with 29 and gets stored at index 2.

The 16 collides with 36 and gets stored at index 3.

The 30 collides twice, first with 36 at index 2, then with 16 at index 3, before being stored at index 4.

Three of the keys had collsions, but the total number of collisions was 4.

29 36 16 30

a) 2

b) 3

c) 4

d) 5

Ans is c) but i am getting b)....Please explain how answer can be c)