GATE / CS ARCHIVE

GATE CSE 2014 SET 1 / QUESTION 40

GATE CSE 2014 Set 1 Q40

Data Structures · Hashing · Full GATE CSE 2014 Set 1 paper

GATE 2014 Set 1, Q40 2 marks · MCQ
Report issue

Hashing

Question 40, GATE 2014: A nine-slot hash table uses h(k)=k mod 9 and chaining. Insert keys 5,28,19,15,20,33,12,17,10 in that order. What are the maximum, minimum and average chain lengths over all slots? A: 3,0,1. B: 3,3,3. C: 4,0,1. D: 3,0,2.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Step through it (11 steps)

1. Method and setup. Compute each key’s remainder, then count keys in each slot. Chaining does not probe or relocate a colliding key to another slot. Include empty slots when finding the minimum and when averaging: average chain length over the table is total keys divided by total slots.

2. Work through the result and its assumptions. The residues modulo 9 are 5, 1, 1, 6, 2, 6, 3, 8, 1. Slot1 has 3 keys; slots 0, 4, 7 are empty; all 9 slots together hold 9 keys, so average length 1. Maximum3, minimum 0, average 1: A.

Original paper, page 17 · Answer key