Data Structures & AlgorithmsVery hardGATE CS

A hash table of size 11 uses double hashing: the probe sequence for key k is (k mod 11 + i · (7 − (k mod 7))) mod 11 for i = 0, 1, 2, .... The keys 41, 52, 63, 30, 74, 19, 85 are inserted in this order. In which slot does key 19 end up?

  1. A. 5
  2. B. 0
  3. C. 2
  4. D. 10

Correct answer: D. 10

Insert in order, probing until an empty slot: the final slots are [8, 1, 4, 2, 0, 10, 3], so 19 lands in slot 10. With plain linear probing it would land in slot 2, because the step for 19 is 7 − (19 mod 7) = 2, not 1.

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

Exams that ask this topic