Given the following input and the hash function mod , which of the following statements are true?
-
hash to the same value
-
hash to the same value
-
All elements hash to the same value
-
Each element hashes to a different value
View worked solution
Answer: C
The hash function is defined as , which simply returns the last digit (units digit) of the integer .
Let's compute the hash value for each element in the input list:
Now, let's evaluate the given statements:
- Statement I: hash to the same value.
Since , this statement is True. - Statement II: hash to the same value.
Since , this statement is True. - Statement III: All elements hash to the same value.
This is False as different elements yield different hash values (e.g., ). - Statement IV: Each element hashes to a different value.
This is False because there are multiple collisions (e.g., and both hash to ).
Therefore, only statements I and II are true, which corresponds to option C.
Free practice · Your answers on this page are not saved.
