Skip to main content

GATE CSE 2014Data Structures › Hashing & Complexity AnalysisVerified

GATE CSE 2014 PYQ: Consider a hash table with 100 100 100 slots. Collisions are resolved using chaining. Assuming simple…

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?

  1. A
    (97×97×97)/1003(97 \times 97 \times 97) / 100^3
    Correct answer
  2. B
    (99×98×97)/1003(99 \times 98 \times 97) / 100^3
  3. C
    (97×96×95)/1003(97 \times 96 \times 95) / 100^3
  4. D
    (97×96×95/(3!×1003)(97 \times 96 \times 95 / (3! \times 100^3)

Answer

(A) ( 97 × 97 × 97 ) / 10 0 3 (97 \times 97 \times 97) / 100^3 ( 97 × 97 × 97 ) /10 0 3

Approach

The first 3 slots remain unfilled exactly when each of the 3 inserted keys hashes into one of the other 97 slots. Since hashing is uniform and independent across insertions, each insertion has probability 97/100 of avoiding the first 3 slots, so multiply this probability three times.

The first 3 slots are unfilled iff all 3 inserted elements hash to slots 4 through 100. Each insertion has probability 97/100 of doing so, independently. Hence the probability is $(97/100)^3 =$ (97 × 97 × $97)/100^3$, matching option A.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.