Data Structures & AlgorithmsVery hardGATE CS · ICPC regional

A table of size 11 uses double hashing with h1(k) = k mod 11 and h2(k) = 1 + (k mod 9), probe position (h1 + i*h2) mod 11. Keys 5, 16, 27 are inserted in this order, then 38. At which slot does 38 finish?

  1. A. 7
  2. B. 8
  3. C. 0
  4. D. 3

Correct answer: B. 8

5, 16, 27 land in 5, 2 (16: 5 full, step 8) and 6 (27: 5, 5+1=6). For 38, h1 = 5 and h2 = 1 + 2 = 3: probe 5 (full), then 8 (empty). Dropping the '1 +' gives step 2 and slot 7; taking h2 from h1 (step 6) gives 0, and 3 is h2 itself.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic