Multiple choice

Consider a hashing function that resolves collision by quadratic probing. Assume the address space to be indexed from 1 to 8. If a collision occurs at position 4, which of the following locations will never be probed?

  1. 4

  2. 5

  3. 8

  4. 2

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

Quadratic probing uses the sequence (h(k) + i^2) mod m. Starting at 4 with m=8, the sequence is 4, (4+1) mod 8 = 5, (4+4) mod 8 = 0 (or 8 if 1-indexed), (4+9) mod 8 = 5, (4+16) mod 8 = 4. Since the probe sequence repeats, locations like 2, 3, 6, and 7 are never reached.