ProgrammingHard

A table of size 5 uses h(k) = k % 5 with linear probing. Keys 15, 5, 10 and 3 are inserted in that order. How many slots are examined when searching for 15 afterwards?

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

Correct answer: B. 1

15 is inserted first and takes slot 0; 5 and 10 then probe on to slots 1 and 2, and 3 goes to slot 3. Searching for 15 finds it at slot 0, so one slot is examined.

More C Programming questions

Exams that ask this topic