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?
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.
-
The hash table contains slots: .
-
Under the simple uniform hashing assumption:
- Each key is equally likely to hash to any of the slots, independently of where other keys have hashed.
- For any single insertion, the probability of choosing any specific slot is .
-
Condition for the First Three Slots Remaining Unfilled:
- The first three slots (slots ) must receive zero keys.
- That is, each inserted key must hash into one of the remaining slots.
- For any individual key, the probability that it falls into one of the other slots is:
-
Three Independent Insertions:
- Because the three key insertions are independent events:
- Because the three key insertions are independent events:
This corresponds to option A.
A
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.