Question discussion

A hash table of size 7 uses double hashing with h1(k) = k mod 7 and h2(k) = 5 − (k mod 5). The keys 14, 21 and 28 are inserted in this orde…

2106Medium DSSSB TGT Computer Science 0 replies 1 views
0

A hash table of size 7 uses double hashing with h1(k) = k mod 7 and h2(k) = 5 − (k mod 5). The keys 14, 21 and 28 are inserted in this order. In which slot is the key 28 stored?

  • A0
  • B6
  • C4
  • D2
Correct answer: D

Explanation

14 goes to slot 0; 21 collides at 0 and its step is 5 − 1 = 4, so it goes to slot 4; 28 collides at 0 with step 5 − 3 = 2, so it is stored in slot 2.

Discussion 0

Nobody has replied yet. Start the discussion!