← Quiz: String Matching — KMP and Rabin-Karp: all 10 questions
Quiz: String Matching — KMP and Rabin-Karp · Question 7 of 10
In Rabin-Karp, why compare the letters when two hashes are equal?
In Rabin-Karp, why compare the letters when two hashes are equal?
- A.To make the code longer
- B.Hashes are always different for different strings
- C.To compute the next hash
- D.Different strings can have the same hash (a collision), so equal hashes do not prove a match
Answer & explanation
Correct answer: Different strings can have the same hash (a collision), so equal hashes do not prove a match
With a modulus, many strings share each hash value; a letter check removes false matches.
Can you get the rest right without peeking?
Take the timed Quiz: String Matching — KMP and Rabin-Karp quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →