Data Structures & AlgorithmsHardAmazon · Microsoft OA

A hash table with separate chaining and simple uniform hashing has n keys in m buckets (load factor α = n/m). What is the expected time of an unsuccessful search, and what keeps it O(1)?

  1. A. Θ(log n); balanced trees in each bucket
  2. B. Θ(α²); using a prime table size
  3. C. Θ(n); nothing can keep it constant
  4. D. Θ(1 + α); resizing keeps α bounded by a constant

Correct answer: D. Θ(1 + α); resizing keeps α bounded by a constant

An unsuccessful search hashes (O(1)) and scans one chain of expected length α. Doubling the table when α exceeds a threshold keeps α = O(1), and amortised resizing cost stays O(1) per insert.

More Coding Interview Problems questions

Exams that ask this topic