ProgrammingModerate

A hash table with 2^20 slots holds 2 x 10^5 keys and uses a good hash. What is the expected cost of a successful lookup?

  1. A. About constant time, since the load factor is near 0.2
  2. B. About linear time, since every key collides
  3. C. About n^2 time for the whole set
  4. D. About log n with a sorted array

Correct answer: A. About constant time, since the load factor is near 0.2

A load factor of 0.2 keeps chains short, so the expected cost of a lookup is close to a constant.

More C Programming questions

Exams that ask this topic