GATE Computer ScienceHardGATE CS (PYQ pattern)

A hash table of size 13 uses double hashing with h1(k) = k mod 13, h2(k) = 1 + (k mod 11) and probe sequence (h1 + i·h2) mod 13. The keys 18, 41, 22, 44, 59, 32 are inserted in that order, then 31. In which slot does 31 land?

  1. A. 2
  2. B. 5
  3. C. 7
  4. D. 12

Correct answer: D. 12

After the first six keys slots 5, 2, 9, 6, 7 and 4 are filled. For 31: h1 = 5 (filled) and h2 = 1 + 9 = 10, so i = 1 gives slot 2 (filled) and i = 2 gives (5 + 20) mod 13 = 12, which is free.

More Programming and Data Structures (GATE) questions

Exams that ask this topic