Skip to main contentSkip to solution

Consider the list= [34, 16, 2, 26, 80]

If the hash function is given by ([i] % 10), which of the elements will create a collision situation?

Solution

✅ Correct Option: 1

A collision occurs when two elements get the same hash value. Here the hash is the remainder on dividing by 10, which is the last digit of the number.

34 mod 10=434 \bmod 10 = 4

16 mod 10=616 \bmod 10 = 6

2 mod 10=22 \bmod 10 = 2

26 mod 10=626 \bmod 10 = 6

80 mod 10=080 \bmod 10 = 0

Only 16 and 26 share a hash value: 16 mod 10=26 mod 10=616 \bmod 10 = 26 \bmod 10 = \boxed{6}

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question