GATE DA 2025 · Hash Tables

MCQ · 1 mark · Problem PROG-DSTR-0076

Consider a hash table of size 10 with indices \(\{0, 1, \dots, 9\}\), with the hash function\(h(x) = 3x \mod 10\), where linear probing is used to handle collisions. The hash table is initially empty and then the following sequence of keys is inserted into the hash table: 1, 4, 5, 6, 14, 15. The indices where the keys 14 and 15 are stored are, respectively:
  1. A
    2 and 5
  2. B
    2 and 6
  3. C
    4 and 5
  4. D
    4 and 6

Solve it on GATE DA practice →More Basic Data Structures problems

Show the worked solution\[\boxed{h(x)=3x \bmod 10,\quad\text{on a collision try } i+1,\ i+2,\ \ldots}\]\(1\to3\), \(4\to12\bmod10=2\), \(5\to5\), \(6\to18\bmod10=8\).\(14\to42\bmod10=2\): slot 2 holds 4 and slot 3 holds 1, so 14 goes to slot 4.\(15\to45\bmod10=5\): slot 5 holds 5, so 15 goes to slot 6.Answer: D

GATE DA practice: past exam problems by chapter, with worked solutions · gatedaprep.com