Question:

Consider a hash table \( P[0,1,\ldots,10] \) that is initially empty. The hash table is maintained using open addressing with linear probing. The hash function used is \( h(x) = (x+7) \bmod 11 \).
Consider the following sequence of insertions performed on \( P \):
\[ 1, 13, 22, 15, 11, 24 \]
Which of the following positions in the hash table is/are empty after these insertions are performed?

Show Hint

Simulate each insertion in order, computing h(x) = (x+7) mod 11, and moving to the next slot (wrapping past index 10 back to 0) whenever there is a collision.
Updated On: Jul 22, 2026
  • 0
  • 10
  • 2
  • 1
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Step 1: Recall how linear probing resolves collisions.
To insert key x, compute its home slot \( h(x) = (x+7) \bmod 11 \). If that slot is empty, place x there; if occupied, probe the next slot \( (h(x)+1) \bmod 11 \), then the next, wrapping from index 10 back to index 0, until an empty slot is found.
Step 2: Insert 1.
\( h(1) = 8 \bmod 11 = 8 \). Slot 8 empty, place 1 at index 8.
Step 3: Insert 13.
\( h(13) = 20 \bmod 11 = 9 \). Slot 9 empty, place 13 at index 9.
Step 4: Insert 22.
\( h(22) = 29 \bmod 11 = 7 \). Slot 7 empty, place 22 at index 7.
Step 5: Insert 15.
\( h(15) = 22 \bmod 11 = 0 \). Slot 0 empty, place 15 at index 0.
Step 6: Insert 11.
\( h(11) = 18 \bmod 11 = 7 \). Slot 7 occupied (22); probe 8, occupied (1); probe 9, occupied (13); probe 10, empty, place 11 at index 10.
Step 7: Insert 24.
\( h(24) = 31 \bmod 11 = 9 \). Slot 9 occupied (13); probe 10, occupied (11); probe 0 (wrap-around), occupied (15); probe 1, empty, place 24 at index 1.
Step 8: Final table state and check the given options.
Occupied indices: 0(15), 1(24), 7(22), 8(1), 9(13), 10(11). Empty indices: 2, 3, 4, 5, 6.
(A) Index 0 holds 15: occupied.
(B) Index 10 holds 11: occupied.
(C) Index 2: never touched, empty.
(D) Index 1 holds 24: occupied.
Step 9: Conclusion.
Among the listed positions, only index 2, option (C), is empty after the insertions.
\[ \boxed{\text{Option (C)}} \]
Was this answer helpful?
0
0