GATE CS 2010 · File Organization & Data Types

MCQ · 2 marks · Problem DBMS-INDX-0051

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}\]How many different insertion sequences of the key values using the same hash function and linear probing will result in the hash table shown above?
  1. A
    10
  2. B
    20
  3. C
    30
  4. D
    40

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

Show the worked solution\[\boxed{\text{a key sits away from its home slot only if every slot it passed was already full}}\]\(42, 23, 34\) and \(46\) are in their home slots \(2, 3, 4, 6\).\(52\) (home \(2\)) is in slot \(5\), so \(42, 23, 34\) must all come before it: the order of \(\{42, 23, 34, 52\}\) has \(52\) last, \(3! = 6\) ways.\(33\) (home \(3\)) is in slot \(7\), so slots \(3\) to \(6\) are full before it: \(33\) is inserted last.\(46\) can go into any of the \(5\) gaps among the first five insertions (slot \(6\) is never taken by \(52\)).\[6 \times 5 = 30\]Answer: C

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