Data Structures & AlgorithmsHardGATE CS · TCS NQT

A hash table of size 11 uses h(k) = k mod 11 with linear probing. Keys 5, 16, 27 and 38 are inserted in this order, and then key 16 is deleted by simply marking its slot empty (no tombstone). A standard search stops at the first empty slot. Which of the keys 5, 27 and 38 can still be found?

  1. A. All three
  2. B. 5 and 27
  3. C. None of the three
  4. D. Only 5

Correct answer: D. Only 5

All four keys hash to slot 5 and occupy slots 5, 6, 7 and 8. After slot 6 is emptied, searches for 27 and 38 stop at slot 6 and fail; only 5, found at its home slot, is still reachable, which is why deletions need tombstones.

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

Exams that ask this topic