Skip to main contentSkip to solution

Take an empty hash table of size 9. The elements to be filled are 38, 57, 81, 77, 33, 44, 70, 37, 40. The table is full at the end of the operation. Consider remainder method as the hash function. What will be the index position of 81, 77, 33 and 38, respectively?

(A) 0

(B) 2

(C) 5

(D) 6

Solution

✅ Correct Option: 1

The hash function is h(k)=k mod 9h(k) = k \bmod 9, so each key goes to the index equal to its remainder.

KeyCalculationIndex
3838=9×4+238 = 9 \times 4 + 22
5757=9×6+357 = 9 \times 6 + 33
8181=9×9+081 = 9 \times 9 + 00
7777=9×8+577 = 9 \times 8 + 55
3333=9×3+633 = 9 \times 3 + 66
4444=9×4+844 = 9 \times 4 + 88
7070=9×7+770 = 9 \times 7 + 77
3737=9×4+137 = 9 \times 4 + 11
4040=9×4+440 = 9 \times 4 + 44

All nine remainders are different, so there are no collisions and the table fills exactly (indices 0 to 8).

81,77,33,38→0, 5, 6, 281, 77, 33, 38 \rightarrow \boxed{0,\ 5,\ 6,\ 2}, which is (A), (C), (D), (B).

Keyboard Shortcuts

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