GATE CS 2010 · File Organization & Data Types

MCQ · 2 marks · Problem DBMS-INDX-0052

A hash table of length 10 uses open addressing with hash function \(h(k) = k \bmod 10\), and linear probing. After inserting 6 values into an empty hash table, the table is as shown below.\[\begin{array}{|c|c|} \hline \text{Slot} & \text{Key} \\ \hline 0 & \\ 1 & \\ 2 & 42 \\ 3 & 23 \\ 4 & 34 \\ 5 & 52 \\ 6 & 46 \\ 7 & 33 \\ 8 & \\ 9 & \\ \hline \end{array}\]Which one of the following choices gives a possible order in which the key values could have been inserted in the table?
  1. A
    46, 42, 34, 52, 23, 33
  2. B
    34, 42, 23, 52, 33, 46
  3. C
    46, 34, 42, 23, 52, 33
  4. D
    42, 46, 33, 23, 34, 52

Solve it on GATE DA practice →More Storage & Indexing problems

Show the worked solution\[\boxed{h(k) = k \bmod 10,\ \text{probe } h, h+1, h+2, \dots}\](A) \(46, 42, 34, 52, 23, 33\): \(52\) goes to slot \(3\), so \(23\) ends in slot \(5\) — incorrect.(B) \(34, 42, 23, 52, 33, 46\): \(52 \to 5\), then \(33 \to 6\), so \(46\) ends in slot \(7\) — incorrect.(C) \(46, 34, 42, 23, 52, 33\): \(46 \to 6, 34 \to 4, 42 \to 2, 23 \to 3, 52 \to 5, 33 \to 7\) — the table above, correct.(D) \(42, 46, 33, 23, 34, 52\): \(33 \to 3\), so \(23\) goes to slot \(4\) — incorrect.Answer: C

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