ProgrammingVery hard

A table of size 10 uses linear probing. Keys 5, 15 and 25 are inserted in that order with h(k) = k % 10. How many slots are examined in total during the three inserts?

  1. A. 3
  2. B. 5
  3. C. 6
  4. D. 9

Correct answer: C. 6

Count every slot looked at, including the one finally used: 5 checks 1 slot, 15 checks slots 5 and 6, and 25 checks 5, 6 and 7, so 1 + 2 + 3 = 6. 3 counts only the occupied slots that caused collisions, and 9 adds a phantom extra probe per insert.

More C Programming questions

Exams that ask this topic