The GATE Grind

GATE 2010 CS (CS1) – Question 63

Algorithms · Searching, Sorting and Hashing · 2 marks · Multiple choice

A ten-slot hash table uses h(k)=k mod 10 and linear probing. Its occupied slots are 2:42, 3:23, 4:34, 5:52, 6:46, 7:33; all others are empty. How many different insertion orders produce this table?

  1. 10
  2. 20
  3. 30
  4. 40

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) 30

Explanation

For 52 to land in five, 42,23,34 must all precede it. For 33 to reach seven, those three plus 52 and 46 must already be present, so 33 is last. Among the 5! orders of the first five keys, 52 must be last relative to {42,23,34,52}, which happens in one quarter. Therefore 120/4=30, C.

More Searching, Sorting and Hashing questions

All Searching, Sorting and Hashing questions →