IAE Academy

GATE 2026 CS1 Q.24: solution and answer

GATE 2026 · CS1Q.24 · 1 mark · MSQ

Consider a hash table that is initially empty. The hash table is maintained using open addressing with linear probing. The hash function used is .

Consider the following sequence of insertions performed on :

Which of the following positions in the hash table is/are empty after these insertions are performed?

  1. (A)

    0

  2. (B)

    10

  3. (C)

    2

  4. (D)

    1

See the question in the paper

Answer and solution

ANSWER

Only position 2 is empty among the given options, so the correct answer is (C).

Official answer: CSource: Official answer key, GATE 2026 CS1 (IIT Guwahati)

  1. The hash table P[0..10] has size 11, all slots initially empty. h(x) = (x+7) mod 11.

  2. Insert 1: h(1) = 8 mod 11 = 8. Slot 8 is empty → P[8] = 1.

  3. Insert 13: h(13) = 20 mod 11 = 9. Slot 9 is empty → P[9] = 13.

  4. Insert 22: h(22) = 29 mod 11 = 7. Slot 7 is empty → P[7] = 22.

  5. Insert 15: h(15) = 22 mod 11 = 0. Slot 0 is empty → P[0] = 15.

  6. Insert 11: h(11) = 18 mod 11 = 7. Slot 7 is occupied (22); probe slot 8 (occupied by 1), slot 9 (occupied by 13), slot 10 (empty) → P[10] = 11.

  7. Insert 24: h(24) = 31 mod 11 = 9. Slot 9 is occupied (13); probe slot 10 (occupied by 11), slot 0 (occupied by 15), slot 1 (empty) → P[1] = 24.

  8. Final table: P[0]=15, P[1]=24, P[2..6]=empty, P[7]=22, P[8]=1, P[9]=13, P[10]=11.

  9. Empty positions are {2, 3, 4, 5, 6}. Among the given options (0, 10, 2, 1), only position 2 (option C) is empty; the answer is (C).

KEY IDEA

Simulate linear probing step by step: compute h(x)=(x+7) mod 11 for each key, and if that slot is occupied, probe the next slots (wrapping around) until an empty one is found.

WATCH OUT FOR

Forgetting to wrap the probe sequence around from index 10 back to index 0 (linear probing is circular), or mis-tracking which slots are already occupied by the time a later collision occurs.

From the GATE 2026 CS1 paper. Every question of this paper · Download the full paper · All 18 Sorting & hashing questions, with notes

More Sorting & hashing questions