🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: String Matching — KMP and Rabin-Karp: all 10 questions

Quiz: String Matching — KMP and Rabin-Karp · Question 9 of 10

When is Rabin-Karp especially useful compared with KMP?

When is Rabin-Karp especially useful compared with KMP?

  1. A.When the pattern is a single letter
  2. B.When searching for many patterns of the same length at once
  3. C.When you need a guaranteed worst-case time
  4. D.When the text is shorter than the pattern
Answer & explanation

Correct answer: When searching for many patterns of the same length at once

Put all pattern hashes in a set and check each window's hash against it.

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 →