Linear probing with wraparound
Hashing

Answer & solution
Official answer: C
Step through it (8 steps)
Givens and goal
An initially empty table has indices 0–10, hash h(x)=(x+7) mod 11, and linear probing. Insert 1,13,22,15,11,24 in that order. Which listed positions are empty: A 0, B 10, C 2, D 1?
Approach
Trace each home slot and each collision in insertion order, wrapping from index 10 to 0.
Step-by-step solution
1. Insert 1: h(1)=8, so place 1 at slot 8. Insert 13: h(13)=20 mod 11=9, so place 13 at 9.
2. Insert 22: h(22)=29 mod 11=7, so place 22 at 7. Insert 15: h(15)=22 mod 11=0, so place 15 at 0.
3. Insert 11: h(11)=18 mod 11=7. Slots 7,8,9 already contain 22,1,13. The first empty slot encountered is 10, so store 11 there.
4. Insert 24: h(24)=31 mod 11=9. Slots 9 and 10 are occupied; probing wraps to 0, which is also occupied. Slot 1 is empty, so place 24 at 1.
5. The final table is:
index: 0 1 2 3 4 5 6 7 8 9 10
value: 15 24 - - - - - 22 1 13 116. Of the four listed indices, only 2 is empty. Select C. The probing rule advances from the current candidate slot; it does not recompute a different hash after each collision.
![Question 36, GATE 2009: Insert 12, 18, 13, 2, 3, 23, 5, 15 in an empty 10-slot table using h(k)=k mod 10 and linear probing. Candidate A stores 2:2, 3:23, 5:15, 8:18; B stores 2:12, 3:13, 5:5, 8:18; C stores slots 2–9 as 12, 13, 2, 3, 23, 5, 18, 15; D chains 2:[12, 2], 3:[13, 3, 23], 5:[5, 15], 8:[18]. Other slots empty. Which is correct?](../../../assets/questions/CS-2009-Q36-1.webp)