A five-digit number a1 a2 a3 a4 a5 needs to be stored in an array by means of hashing. When the hash function is mod (a1+a2+a3+a4+a5, 13) and the number is stored in the array element at the position corresponding to the calculated hash value, which of the following is the position where 54321 is stored in the array? Here, the value of mod (x, 13) is the remainder after dividing x by 13
Explanation:
We need to calculate the position in the array where the number 54321 is stored using the given hash function:
The number is 54321, which has digits:
The hash function is defined as:
Step 1: Sum of the digits
Step 2: Calculate the hash value
The remainder when 15 is divided by 13 is:
Thus,
Conclusion:
The number 54321 will be stored in the array at position 2.
Comments
Post a Comment