Question 2 Five values are inserted in a hash table with size 20.
Sigmoid technical mcq question, verified with a worked answer. Free to practise - no sign-up.
Five values are inserted in a hash table with size 20. Chaining is used to resolve the hash collisions. If the method used for insertion is uniform hashing, then what is the probability that no value is stored in the first 5 slots?
Select an option
Show answer & explanation
Answer: B. B) (15 * 15 * 15 * 15 * 15) / (20 * 20 * 20 * 20 * 20)
For each of the 5 values independently, the probability of avoiding the first 5 slots is (20 - 5)/20 = 15/20. The joint probability is (15/20)^5.
Step-by-step Derivation:
Step 1: Total slots = 20. Slots outside the first 5 = 15.
Step 2: Under uniform hashing, probability for one key = 15/20.
Step 3: For 5 independent keys, probability = (15/20)^5 = (15^5) / (20^5).