Question

Consider a hash table with 100 slots. Collisions are resolved using chaining. Assuming simple uniform hashing, what is the probability that the first 3 slots are unfilled after the first 3 insertions?

Choose one option
Official answer and solution
Official answer
A
From
Official GATE 2014 answer key

Solution

Use simple uniform hashing to find the independent probability that all three insertions avoid the first three slots.

  1. The hash table contains 100100 slots: {0,1,2,…,99}\{0, 1, 2, \dots, 99\}.

  2. Under the simple uniform hashing assumption:

    • Each key is equally likely to hash to any of the 100100 slots, independently of where other keys have hashed.
    • For any single insertion, the probability of choosing any specific slot is 1100\frac{1}{100}.
  3. Condition for the First Three Slots Remaining Unfilled:

    • The first three slots (slots 0,1,20, 1, 2) must receive zero keys.
    • That is, each inserted key must hash into one of the remaining 100−3=97100 - 3 = 97 slots.
    • For any individual key, the probability that it falls into one of the other 9797 slots is:
      P=97100.P = \frac{97}{100}.
  4. Three Independent Insertions:

    • Because the three key insertions are independent events:
      P(all 3 keys avoid first 3 slots)=(97100)3=97×97×971003.P(\text{all 3 keys avoid first 3 slots}) = \left(\frac{97}{100}\right)^3 = \frac{97 \times 97 \times 97}{100^3}.

This corresponds to option A.

Final answer

A

Common trap

Treating hashing as sampling without replacement (which would give 97 * 96 * 95), but hash functions can hash multiple keys to the same slot.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 3
Question
50 of 65, printed as CS Q.40
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.