GATE / CS ARCHIVE

GATE CSE 2004 / QUESTION 7

Hash collisions under modulo ten

Data Structures · Hashing · Full GATE CSE 2004 paper

GATE 2004, Q7 1 mark · MCQ
Report issue

Hashing

Question 7, GATE 2004: Hash the input 4322,1334,1471,9679,1989,6171,6173,4199 using h(x)=x mod 10. Which statements hold? (1) 9679,1989,4199 collide. (2) 1471,6171 collide. (3) All inputs hash to the same value. (4) Every input has a different hash value.
Options:
(A) 1 only
(B) 2 only
(C) 1 and 2 only
(D) 3 or 4
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. The hash is the last decimal digit.9679,1989,4199 all map to 9, while 1471 and 6171 both map to 1. The remaining values map to 2,4,3.

2. Thus statements 1 and 2 only are true, C.

3. Teaching check: The eight hash values in input order are 2,4,1,9,9,1,3,9. This explicit list both verifies the two claimed collisions and refutes the “all equal” and “all different” alternatives. Collision means equal hash output, not equal original keys.

Original paper, page 1