Computer Sciences > GATE 2026 SET-2 > Data Structures
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 _______.

Correct : 3

The correct answer is 3.
We apply the hash function h(k) = k mod 9 to each of the 9 keys and group them by their hash slot. Collisions are resolved by chaining, so each slot holds a linked list of all keys that map to it.
Computing the hash for each key: 5 mod 9 = 5, 28 mod 9 = 1, 19 mod 9 = 1, 15 mod 9 = 6, 26 mod 9 = 8, 33 mod 9 = 6, 12 mod 9 = 3, 17 mod 9 = 8, 10 mod 9 = 1.
Grouping by slot: Slot 1 → {28, 19, 10} — chain length 3. Slot 6 → {15, 33} — chain length 2. Slot 8 → {26, 17} — chain length 2. Slot 3 → {12} — chain length 1. Slot 5 → {5} — chain length 1. All other slots are empty.
The longest chain is at slot 1, which contains three keys — 28, 19, and 10 — all of which yield a remainder of 1 when divided by 9. The length of the longest chain is therefore 3.

Similar Questions

Which one of the following sequences when stored in an array at locations A[1],...,A[10] forms a max-heap?
#950 MCQ
Let SLLdel be a function that deletes a node in a singly-linked list given a pointer to the node and a pointer to the head of the list. Similarly, let DLLdel be...
#951 MCQ
An algorithm has to store several keys generated by an adversary in a hash table. The adversary is malicious who tries to maximize the number of collisions. Let...
#957 MCQ

Related Topics

hash table chaining GATE 2026 GATE CS 2026 Set-2 Q30 h(k) = k mod 9 hash function GATE longest chain hash table GATE data structures hashing GATE 2026 collision resolution chaining GATE hash table collision GATE CSE 2026 keys mod 9 GATE data structures

Unique Visitor Count

Total Unique Visitors

Loading......