Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and…

2004

Given the following input (4322, 1334, 1471, 9679, 1989, 6171, 6173, 4199) and the hash function x mod 10, which of the following statements are true?


1.    9679, 1989, 4199 hash to the same value
2.    1471, 6171 hash to the same value
3.    All elements hash to the same value
4.    Each element hashes to a different value 

  1. A.

    1 only

  2. B.

    2 only

  3. C.

    1 and 2 only

  4. D.

    3 or 4

Attempted by 287 students.

Show answer & explanation

Correct answer: C

Compute the hash x mod 10 (equivalent to the last digit of x).

  • 4322 hashes to 2 (last digit 2).

  • 1334 hashes to 4 (last digit 4).

  • 1471 hashes to 1 (last digit 1).

  • 9679 hashes to 9 (last digit 9).

  • 1989 hashes to 9 (last digit 9).

  • 6171 hashes to 1 (last digit 1).

  • 6173 hashes to 3 (last digit 3).

  • 4199 hashes to 9 (last digit 9).

From these results:

  • Statement 1 is true: 9679, 1989, and 4199 all hash to 9.

  • Statement 2 is true: 1471 and 6171 both hash to 1.

  • Statement 3 is false: not all elements hash to the same value (their last digits differ).

  • Statement 4 is false: there are collisions (multiple elements share the same hash), so they are not all different.

Correct conclusion: statements 1 and 2 only.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir