Data Structures & AlgorithmsHardProduct Company SDE pattern

What is printed? (expected probes in a hash table)

What is printed? (expected probes in a hash table)
alpha = 0.75
chaining = 1 + alpha / 2
linear_hit = 0.5 * (1 + 1 / (1 - alpha))
linear_miss = 0.5 * (1 + 1 / (1 - alpha) ** 2)
print(round(chaining, 3), linear_hit, linear_miss)
  1. A. 1.75 2.5 8.5
  2. B. 1.375 4.0 16.0
  3. C. 1.375 2.5 4.5
  4. D. 1.375 2.5 8.5

Correct answer: D. 1.375 2.5 8.5

Standard estimates (Knuth): successful search with chaining ≈ 1 + α/2; with linear probing ≈ ½(1 + 1/(1 − α)) for hits and ½(1 + 1/(1 − α)²) for misses. At α = 0.75 a miss already costs about 8.5 probes, which is why open-addressing tables resize around α ≈ 0.5–0.75.

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

Exams that ask this topic