ProgrammingVery hard

Keys 2, 7 and 12 are inserted into a table of size 5 with h(k) = k % 5 using linear probing. In which slot does 12 end up?

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

Correct answer: B. 4

2 takes slot 2, 7 hashes to slot 2 and probes to 3, and 12 hashes to slot 2, which is taken, then slot 3 is also taken, so it lands at slot 4.

More C Programming questions

Exams that ask this topic