GATE / CS ARCHIVE

GATE CSE 2021 SET 1 / QUESTION 47

GATE CSE 2021 Set 1 Q47

Data Structures · Hashing · Full GATE CSE 2021 Set 1 paper

GATE 2021 Set 1, Q47 2 marks · MSQ
Report issue

Hashing

Question 47, GATE 2021: Dynamic hashing uses a four-entry table indexed by the lowest two bits of four-bit integer keys. Collisions split into a binary tree by the third-lowest bit (0 left,1 right), then the fourth-lowest bit; split only when required. Target diagram: bucket 00 empty; bucket 01 splits at bit 3, with a leaf on branch 0 and a bit-4 split with two leaves on branch 1; bucket 10 splits at bit 3 into two leaves; bucket 11 has one leaf. Which insertion sequence yields it? A 5,9,4,13,10,7; B 9,5,10,6,7,1; C 10,9,6,7,5,13; D 9,5,13,6,10,14.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: C

The displayed shape requires bucket 00 empty; bucket 01 with one key having third-lowest bit 0 and two keys having third-lowest bit 1, separated by the fourth bit; bucket 10 with one key on each third-bit branch; and bucket 11 with one key. C supplies bucket01={9(1001), 5(0101), 13(1101)}, bucket10={10(1010), 6(0110)}, and bucket11={7(0111)}, exactly that structure. A puts 4 in bucket00, B splits the zero third-bit branch of bucket01 because it contains 1 and 9, and D leaves bucket11 empty while putting three keys in bucket10. Only C matches.

Process C explicitly: 10=1010 enters bucket10; 9=1001 enters bucket01; 6=0110 collides in bucket10 but differs from 10 in bit3, making its two leaves. Key 7=0111 occupies bucket11. Key 5=0101 collides with 9 in bucket01 and goes to its bit3=1 branch, whereas 9 has bit3=0. Finally 13=1101 joins 5 on bit3=1 and differs in bit4, producing exactly the extra split. A premature split without collision would violate the stated rule.

Original paper, page 38 · Answer key