Question:medium

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: Aug 3, 2026
  • 0
  • 10
  • 2
  • 1
Show Solution

The Correct Option is C

Solution and Explanation

Let's track the hash table as a running occupancy list after each insertion, rather than computing all hash values and filling in afterward, to visualize how collisions get resolved.

Step 1: Compute all six hash values up front using \(h(x) = (x+7) \mod 11\).

\(h(1)=8\), \(h(13)=9\), \(h(22)=7\), \(h(15)=0\), \(h(11)=7\), \(h(24)=9\).

Step 2: Track occupancy slot by slot.

After inserting 1, 13, 22, 15 (all land on their home slots 8, 9, 7, 0 with no collision), the table looks like: slot0=15, slot7=22, slot8=1, slot9=13, and slots 1-6 and 10 are still empty.

Step 3: Insert 11, home slot 7, which is taken.

Walking forward from slot 7: slot7 taken, slot8 taken, slot9 taken, slot10 free. So 11 goes to slot 10. Now slots 0,7,8,9,10 are filled; slots 1-6 remain empty.

Step 4: Insert 24, home slot 9, which is taken.

Walking forward from slot 9: slot9 taken, slot10 taken, wrap to slot0 taken, slot1 free. So 24 goes to slot 1. Now the filled slots are 0,1,7,8,9,10; the only slots left empty are 2, 3, 4, 5, 6.

Step 5: Match against the answer choices.

The choices given are indices 0, 10, 2, and 1. Checking against our empty-slot list of 2,3,4,5,6: index 0 is filled (15), index 10 is filled (11), index 1 is filled (24), and only index 2 is genuinely empty.

Hence the only index among the options that is empty after all insertions is 2.

Was this answer helpful?
0


Questions Asked in GATE CS exam