Skip to content
Official PYQ · 2009

GATE CS 2009 Q36 — Arrays, Stacks and Queues

Explain with AI

The keys 12,18,13,2,3,23,512, 18, 13, 2, 3, 23, 5 and 1515 are inserted into an initially empty hash table of length 1010 using open addressing with hash function h(k)=kmod  10h(k) = k \mod 10 and linear probing. What is the resultant hash table?

Choose one option
View worked solution

Answer: C

To find the resultant hash table, we insert the keys one by one into an initially empty hash table of size 1010 (with indices 00 to 99) using the hash function h(k)=k mod 10h(k) = k \bmod 10 and linear probing to resolve collisions.

Let's trace the insertion of each key step-by-step:

  1. Insert 12:
    h(12)=12 mod 10=2h(12) = 12 \bmod 10 = 2. Slot 22 is empty. Insert 12 at slot 22.
  2. Insert 18:
    h(18)=18 mod 10=8h(18) = 18 \bmod 10 = 8. Slot 88 is empty. Insert 18 at slot 88.
  3. Insert 13:
    h(13)=13 mod 10=3h(13) = 13 \bmod 10 = 3. Slot 33 is empty. Insert 13 at slot 33.
  4. Insert 2:
    h(2)=2 mod 10=2h(2) = 2 \bmod 10 = 2. Slot 22 is occupied by 1212.
    Probe slot 33: occupied by 1313.
    Probe slot 44: empty. Insert 2 at slot 44.
  5. Insert 3:
    h(3)=3 mod 10=3h(3) = 3 \bmod 10 = 3. Slot 33 is occupied by 1313.
    Probe slot 44: occupied by 22.
    Probe slot 55: empty. Insert 3 at slot 55.
  6. Insert 23:
    h(23)=23 mod 10=3h(23) = 23 \bmod 10 = 3. Slot 33 is occupied.
    Probe slot 44: occupied.
    Probe slot 55: occupied.
    Probe slot 66: empty. Insert 23 at slot 66.
  7. Insert 5:
    h(5)=5 mod 10=5h(5) = 5 \bmod 10 = 5. Slot 55 is occupied.
    Probe slot 66: occupied.
    Probe slot 77: empty. Insert 5 at slot 77.
  8. Insert 15:
    h(15)=15 mod 10=5h(15) = 15 \bmod 10 = 5. Slot 55 is occupied.
    Probe slot 66: occupied.
    Probe slot 77: occupied.
    Probe slot 88: occupied by 1818.
    Probe slot 99: empty. Insert 15 at slot 99.

The final state of the hash table is:

Index Value
0—
1—
212
313
42
53
623
75
818
915

This matches the table given in Option C.

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

Published
Report a correction
Keep exploringMore Arrays, Stacks and Queues questions