GATE / CS ARCHIVE

GATE CSE 2025 SET 1 / QUESTION 65

Tracing double-hash probing positions

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

GATE 2025 Set 1, Q65 2 marks · NAT
Report issue

Hashing

Question 65, GATE 2025: An initially empty hash table has m=11 slots. h1(k)=k mod 11, h2(k)=1+(k mod 7), and probe i uses [h1(k)+i·h2(k)] mod 11, starting at i=0. Insert 63,50,25,79,67,24 in that order. In which slot does 24 end up? The formula yields a zero-based index; the official range also accepts the corresponding one-based slot number.
Tap to enlarge
Answer & solution

Official answer: 10 to 11

Our answer: 10

Step through it (8 steps)

Approach: Insert the earlier keys first, because their occupied positions determine how many probes key 24 needs.
For the first five keys the primary hash locations are 63 mod 11=8, 50 mod 11=6, 25 mod 11=3, 79 mod 11=2 and 67 mod 11=1. All differ, so each key is placed on its first probe. Occupied indices are therefore {1,2,3,6,8}.
For 24, h1=24 mod 11=2 and h2=1+(24 mod 7)=1+3=4. Probe i=0 checks index 2, occupied by 79. Probe i=1 checks (2+4) mod 11=6, occupied by 50. Probe i=2 checks (2+8) mod 11=10, which is empty, so 24 is stored there.
The derived index is 10. This is the eleventh slot if slots are described with one-based ordinal numbers. Preserve the official accepted interval 10–11, but use 10 when interpreting the given modulo formula literally. The second hash is the step size, not a replacement initial index.

Original paper, page 64 · Answer key