GateAI
Searching, Sorting and Hashing

GATE CSE 2026 Set 2 · Q30

NAT1 markEasy

Time

The keys 5, 28, 19, 15, 26, 33, 12, 17, 10 are inserted into a hash table using the hash function h(k)=k mod 9h(k) = k \bmod 9. The collisions are resolved by chaining. After all the keys are inserted, the length of the longest chain is _______. (answer in integer)

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 3

Searching, Sorting and Hashing

Compute the hash value h(k)=k mod 9h(k) = k \bmod 9 for each key:

  • 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(26)=26 mod 9=8h(26) = 26 \bmod 9 = 8

  • 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 into the slots:

  • Slot 1: {28,19,10}\{28, 19, 10\} (Chain length = 3)

  • Slot 3: {12}\{12\} (Chain length = 1)

  • Slot 5: {5}\{5\} (Chain length = 1)

  • Slot 6: {15,33}\{15, 33\} (Chain length = 2)

  • Slot 8: {26,17}\{26, 17\} (Chain length = 2)

The maximum number of keys hashed to any single slot is in slot 1, which contains 3 keys.

Therefore, the length of the longest chain is 3.

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 Q30 of the GATE CSE 2026 Set 2 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. 5 of them are 1-mark NAT questions like this one, and GATE CSE 2026 Set 2 has 2.

How GATE tests Searching, Sorting and Hashing

More from GATE CSE 2026 Set 2

Share this solution

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

GateAI solution cardGATE CSE 2026 Set 2 · Q30 · NAT

The keys 5, 28, 19, 15, 26, 33, 12, 17, 10 are inserted into a hash table using the hash function h(k) = k mod 9. The collisions are resolved by chaining. After all the keys are inserted, the length of the longest chain is … (answer in integer)

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.