Insert the characters of the string K R P C S N Y T J M into a hash table of…
20242017
Insert the characters of the string K R P C S N Y T J M into a hash table of size 10. Use the hash function
h(x) = ( ord(x) – ord("a") + 1 ) mod10
If linear probing is used to resolve collisions, then the following insertion causes collision
- A.
Y
- B.
C
- C.
M
- D.
P
Attempted by 84 students.
Show answer & explanation
Correct answer: C
Using A=1, B=2, ..., Z=26 and mod 10: K->1, R->8, P->6, C->3, S->9, N->4, Y->5, T->0, J->0, and M->3. Among the listed insertions, M hashes to index 3, which is already occupied by C, so M causes a collision.
A video solution is available for this question — log in and enroll to watch it.