Question:

Consider a hash table 𝑃[0, 1, … , 10] that is initially empty. The hash table is
maintained using open addressing with linear probing. The hash function used is
β„Ž(π‘₯) = (π‘₯+ 7) mod 11.
Consider the following sequence of insertions performed on 𝑃:
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 using h(x) = (x+7) mod 11 with linear probing on collisions, then check which of the given indices was never filled.
Updated On: Jul 7, 2026
  • 0
  • 10
  • 2
  • 1
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

We have a hash table P[0..10] (11 slots) using open addressing with linear probing and hash function \(h(x) = (x+7) \bmod 11\). We insert 1, 13, 22, 15, 11, 24 in order and must find the empty slots afterward.

Step 1: Insert 1.

\(h(1) = (1+7) \bmod 11 = 8\). Slot 8 is empty, so place 1 at index 8.

Step 2: Insert 13.

\(h(13) = (13+7) \bmod 11 = 20 \bmod 11 = 9\). Slot 9 is empty, so place 13 at index 9.

Step 3: Insert 22.

\(h(22) = (22+7) \bmod 11 = 29 \bmod 11 = 7\). Slot 7 is empty, so place 22 at index 7.

Step 4: Insert 15.

\(h(15) = (15+7) \bmod 11 = 22 \bmod 11 = 0\). Slot 0 is empty, so place 15 at index 0.

Step 5: Insert 11.

\(h(11) = (11+7) \bmod 11 = 18 \bmod 11 = 7\). Slot 7 is occupied (22), so probe forward: slot 8 is occupied (1), slot 9 is occupied (13), slot 10 is empty. Place 11 at index 10.

Step 6: Insert 24.

\(h(24) = (24+7) \bmod 11 = 31 \bmod 11 = 9\). Slot 9 is occupied (13), probe slot 10 (occupied by 11), wrap around to slot 0 (occupied by 15), then slot 1 is empty. Place 24 at index 1.

Step 7: List the final table and identify empty slots.

Final table: index 0 = 15, index 1 = 24, index 2 = empty, index 3 = empty, index 4 = empty, index 5 = empty, index 6 = empty, index 7 = 22, index 8 = 1, index 9 = 13, index 10 = 11.

So the empty slots are 2, 3, 4, 5, and 6. Among the given options (0, 10, 2, 1), only index 2 is empty; indices 0, 10, and 1 are all occupied.

\[ \boxed{\text{Option C (index 2)}} \]
Was this answer helpful?
0
0

Top GATE CS Computer Science and IT Engineering Questions

View More Questions