GATE / CS ARCHIVE

GATE CSE 2022 / QUESTION 16

GATE CSE 2022 Q16

Data Structures · Hashing · Full GATE CSE 2022 paper

GATE 2022, Q16 1 mark · MCQ
Report issue

Hashing

Question 16, GATE 2022: Hash n keys into m slots, using simple-uniform hash function h1 for odd keys and h2 for even keys. Find the expected occupancy of a fixed slot. A m/n; B n/m; C 2n/m; D n/(2m).
Tap to enlarge
Your answer
Answer & solution

Official answer: B

For a fixed slot, each key maps there with probability 1/m under whichever uniform hash function applies to its parity. Summing n indicator expectations gives n/m. Independence between all indicators is unnecessary for this expectation. Thus B.

Let Ii=1 if key i lands in the chosen slot, and 0 otherwise. Occupancy X=ΣIi. Whether i is odd or even, E[Ii]=1/m, so E[X]=ΣE[Ii]=n/m. Using two functions does not double the number of keys or halve the table.

Original paper, page 13 · Answer key