GateAI
Searching, Sorting and Hashing

GATE CSE 2014 Set 1 · Q40

MCQ2 marksEasy

Time

Consider a hash table with 9 slots. The hash function is h(k)=k mod 9h(k) = k \bmod 9. The collisions are resolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33, 12, 17, 10. The maximum, minimum, and average chain lengths in the hash table, respectively, are

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: A) 3, 0, and 1

Searching, Sorting and Hashing

We are given a hash table with m=9m = 9 slots (indices 00 to 88) and the hash function h(k)=k mod 9h(k) = k \bmod 9.

Let us compute the slot index for each of the 9 inserted keys:

  • h(5)=5 mod 9=5h(5) = 5 \bmod 9 = 5

  • h(28)=28 mod 9=1h(28) = 28 \bmod 9 = 1

  • h(19)=19 mod 9=1h(19) = 19 \bmod 9 = 1

  • h(15)=15 mod 9=6h(15) = 15 \bmod 9 = 6

  • h(20)=20 mod 9=2h(20) = 20 \bmod 9 = 2

  • h(33)=33 mod 9=6h(33) = 33 \bmod 9 = 6

  • h(12)=12 mod 9=3h(12) = 12 \bmod 9 = 3

  • h(17)=17 mod 9=8h(17) = 17 \bmod 9 = 8

  • h(10)=10 mod 9=1h(10) = 10 \bmod 9 = 1

Distribution of keys in the slots:

  • Slot 0: None   ⟹  length=0\implies \text{length} = 0

  • Slot 1: 28,19,10  ⟹  length=328, 19, 10 \implies \text{length} = 3

  • Slot 2: 20  ⟹  length=120 \implies \text{length} = 1

  • Slot 3: 12  ⟹  length=112 \implies \text{length} = 1

  • Slot 4: None   ⟹  length=0\implies \text{length} = 0

  • Slot 5: 5  ⟹  length=15 \implies \text{length} = 1

  • Slot 6: 15,33  ⟹  length=215, 33 \implies \text{length} = 2

  • Slot 7: None   ⟹  length=0\implies \text{length} = 0

  • Slot 8: 17  ⟹  length=117 \implies \text{length} = 1

From this distribution:

  • Maximum chain length: 33 (in slot 1)

  • Minimum chain length: 00 (in slots 0, 4, 7)

  • Average chain length: Total number of keysNumber of slots=99=1\frac{\text{Total number of keys}}{\text{Number of slots}} = \frac{9}{9} = 1

Therefore, the values are 3, 0, and 1, which corresponds to option (A).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Searching, Sorting and Hashing previous year question is Q40 of the GATE CSE 2014 Set 1 paper. Find more GATE CSE PYQs on Searching, Sorting and Hashing in Algorithms, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Searching, Sorting and Hashing PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Searching, Sorting and Hashing in GATE CSE

Searching, Sorting and Hashing has 27 GATE CSE PYQs across 20 papers from 2012 to 2026. 7 of them are 2-mark MCQs like this one, and GATE CSE 2014 Set 1 has 3.

How GATE tests Searching, Sorting and Hashing

More from GATE CSE 2014 Set 1

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2014 Set 1 · Q40 · MCQ

Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions are resolved by chaining. The following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33, 12, 17, 10. The maximum, minimum, and average chain lengths in the hash table, respectively, are

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.