Data Structures & AlgorithmsModerateTCS NQT · Infosys pattern

Keys 23, 43, 13 and 27 are inserted in that order into an empty hash table of size 10 with h(k) = k mod 10 and linear probing. At which index does 13 end up?

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

Correct answer: A. 5

23 → 3; 43 → 3 is taken, goes to 4; 13 → 3 and 4 are taken, goes to 5; 27 → 7. Index 3 is only its home slot, not where it is stored.

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

Exams that ask this topic