Data Structures & AlgorithmsVery hardProduct company OA

20 keys are hashed independently and uniformly into 100 slots. What is the EXPECTED number of colliding pairs (unordered pairs of keys that land in the same slot)?

  1. A. 0.2
  2. B. 1.9
  3. C. 2.0
  4. D. 0.19

Correct answer: B. 1.9

There are C(20, 2) = 190 pairs and each collides with probability 1/100, so by linearity of expectation the expected count is 1.9. '2.0' uses 20²/2 instead of 20·19/2; '0.2' divides the number of keys by the number of slots, which is the load factor, not a collision count.

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

Exams that ask this topic