Data Structures & AlgorithmsHardProduct-company MCQ pattern

Keys 88, 61, 14, 52, 18 are inserted via linear probing (h(k) = k mod 7, probe by +1 on collision) into an initially empty table of size 7 (indices 0 to 6). What is the final table, left to right (_ = empty)?

  1. A. 18, 61, 88, 52, _, _, 14
  2. B. 14, 18, _, 52, 88, 61, _
  3. C. 14, _, _, 52, 88, 61, 18
  4. D. 14, _, _, 52, 88/18, 61, _

Correct answer: C. 14, _, _, 52, 88, 61, 18

Each key goes to h(k) = k mod 7, and on a collision the next slot (wrapping around) is tried until an empty one is found. Simulating all insertions in order gives [14, _, _, 52, 88, 61, 18]. Using quadratic probing (+1², +2², ...) instead would give a different table, [14, 18, _, 52, 88, 61, _], since the probe sequence differs after the first collision.

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

Exams that ask this topic