← Quiz: String Matching — KMP and Rabin-Karp: all 10 questions
Quiz: String Matching — KMP and Rabin-Karp · Question 2 of 10
What does lps[i] store in KMP?
What does lps[i] store in KMP?
- A.The length of the longest proper prefix of pat[0..i] that is also a suffix of it
- B.The number of times pat[i] appears in the pattern
- C.The position of the next mismatch
- D.The length of the longest palindrome ending at i
Answer & explanation
Correct answer: The length of the longest proper prefix of pat[0..i] that is also a suffix of it
"Proper" means the prefix cannot be the whole of pat[0..i].
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 →