Data Structures & AlgorithmsVery hardProduct placement · Amazon/Microsoft

A chained hash table stores n = 2,000 keys in m = 500 buckets with simple uniform hashing. What is the expected number of key comparisons in a SUCCESSFUL search?

  1. A. About 4 (α)
  2. B. About 2 (α/2)
  3. C. About 3 (1 + α/2 with α = 4)
  4. D. About 5 (1 + α)

Correct answer: C. About 3 (1 + α/2 with α = 4)

With load factor α = n/m = 4, a successful search examines on average 1 + α/2 − α/(2n) ≈ 3 elements; an unsuccessful search would examine about α = 4 (plus computing the hash).

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

Exams that ask this topic