Skip to content
Official PYQ · 2026

GATE CS 2026 Set 1 Q14 — Searching, Sorting, Hashing

Explain with AI

Consider a hash table P[0,1,…,10]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) mod 11h(x)=(x+7) \bmod 11.

Consider the following sequence of insertions performed on PP :
 1,13, 22, 15, 11, 24\text{ 1,13, 22, 15, 11, } 24
Which of the following positions in the hash table is/are empty after these insertions are performed?

Choose one option
View worked solution

Answer: C

We are given a hash table P[0,1,…,10]P[0, 1, \ldots, 10] of size m=11m = 11. The hash function is h(x)=(x+7) mod 11h(x) = (x + 7) \bmod 11, and collisions are resolved using linear probing.

Let's trace the insertions step-by-step:

  1. Insert 1:
    h(1)=(1+7) mod 11=8h(1) = (1 + 7) \bmod 11 = 8.
    Position 88 is empty. Insert 11 at P[8]P[8].
  2. Insert 13:
    h(13)=(13+7) mod 11=9h(13) = (13 + 7) \bmod 11 = 9.
    Position 99 is empty. Insert 1313 at P[9]P[9].
  3. Insert 22:
    h(22)=(22+7) mod 11=7h(22) = (22 + 7) \bmod 11 = 7.
    Position 77 is empty. Insert 2222 at P[7]P[7].
  4. Insert 15:
    h(15)=(15+7) mod 11=0h(15) = (15 + 7) \bmod 11 = 0.
    Position 00 is empty. Insert 1515 at P[0]P[0].
  5. Insert 11:
    h(11)=(11+7) mod 11=7h(11) = (11 + 7) \bmod 11 = 7.
    Position 77 is occupied. Probing sequentially:
    - Index 88 is occupied.
    - Index 99 is occupied.
    - Index 1010 is empty. Insert 1111 at P[10]P[10].
  6. Insert 24:
    h(24)=(24+7) mod 11=9h(24) = (24 + 7) \bmod 11 = 9.
    Position 99 is occupied. Probing sequentially:
    - Index 1010 is occupied.
    - Index 00 is occupied.
    - Index 11 is empty. Insert 2424 at P[1]P[1].

After all insertions, the occupied positions in the hash table are:

  • P[0]=15P[0] = 15
  • P[1]=24P[1] = 24
  • P[7]=22P[7] = 22
  • P[8]=1P[8] = 1
  • P[9]=13P[9] = 13
  • P[10]=11P[10] = 11

The empty positions are 2,3,4,5,2, 3, 4, 5, and 66. Among the given options, only position 22 (Option C) is empty.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Searching, Sorting, Hashing questions