Data Structures & AlgorithmsVery hardProduct-company MCQ pattern

Keys 18, 41, 22, 44, 59, 32, 31, 96 are inserted in that order into a table of size 13 by double hashing: h₁(k) = k mod 13, h₂(k) = 7 − (k mod 7), probe i at (h₁ + i·h₂) mod 13. At which index is 96 stored?

  1. A. 0
  2. B. 11
  3. C. 12
  4. D. 8

Correct answer: B. 11

Before 96 the table holds 31→0, 41→2, 18→5, 32→6, 59→7, 22→9, 44→10 (44 and 31 collided at 5). For 96, h₁ = 5 and h₂ = 7 − 5 = 2, so it tries 5, 7, 9 (all full) and lands at 11. Linear probing from 5 would have stopped at 8.

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

Exams that ask this topic