guess the next step: Knuth-Morris-Pratt
Before each step plays, guess what it does. The page then shows the step as the run takes it and says why, the same sentence the watch page says there.
Step 2 of 22
Question 1 of 15
Step 2 of 22
Step 3 of 22
Step 4 of 22
Step 5 of 22
Step 6 of 22
Step 7 of 22
Step 8 of 22
Step 9 of 22
Step 10 of 22
Step 11 of 22
Step 12 of 22
Question 1 of 15
Question 1 of 15
Not this time.
You guessed: The pattern letter compared next matches the letter after the border, so the border grows by one.
What the run did:
b is not a, the first letter, and there is no shorter border left to fall back to.
Question 1 of 15
Not this time.
You guessed: The pattern letter compared next is not the letter after the border, so fall back to a shorter border.
What the run did:
b is not a, the first letter, and there is no shorter border left to fall back to.
Question 1 of 15
Right.
You guessed: The pattern letter compared next is not its first letter, and no shorter border is left.
What the run did:
b is not a, the first letter, and there is no shorter border left to fall back to.
Question 2 of 15
Question 2 of 15
Right.
You guessed: The pattern letter compared next matches the letter after the border, so the border grows by one.
What the run did:
a matches the letter after a border of nothing, so the first 3 letters have a border one longer: 1.
Question 2 of 15
Not this time.
You guessed: The pattern letter compared next is not the letter after the border, so fall back to a shorter border.
What the run did:
a matches the letter after a border of nothing, so the first 3 letters have a border one longer: 1.
Question 2 of 15
Not this time.
You guessed: The pattern letter compared next is not its first letter, and no shorter border is left.
What the run did:
a matches the letter after a border of nothing, so the first 3 letters have a border one longer: 1.
Question 3 of 15
Question 3 of 15
Right.
You guessed: The pattern letter compared next matches the letter after the border, so the border grows by one.
What the run did:
b matches the letter after a border 1 letter long, so the first 4 letters have a border one longer: 2.
Question 3 of 15
Not this time.
You guessed: The pattern letter compared next is not the letter after the border, so fall back to a shorter border.
What the run did:
b matches the letter after a border 1 letter long, so the first 4 letters have a border one longer: 2.
Question 3 of 15
Not this time.
You guessed: The pattern letter compared next is not its first letter, and no shorter border is left.
What the run did:
b matches the letter after a border 1 letter long, so the first 4 letters have a border one longer: 2.
Question 4 of 15
Question 4 of 15
Not this time.
You guessed: The pattern letter compared next matches the letter after the border, so the border grows by one.
What the run did:
c is not a, the letter after a border 2 letters long. Fall back to that border's own border, of nothing, and compare again.
Question 4 of 15
Right.
You guessed: The pattern letter compared next is not the letter after the border, so fall back to a shorter border.
What the run did:
c is not a, the letter after a border 2 letters long. Fall back to that border's own border, of nothing, and compare again.
Question 4 of 15
Not this time.
You guessed: The pattern letter compared next is not its first letter, and no shorter border is left.
What the run did:
c is not a, the letter after a border 2 letters long. Fall back to that border's own border, of nothing, and compare again.
Question 5 of 15
Question 5 of 15
Not this time.
You guessed: The pattern letter compared next matches the letter after the border, so the border grows by one.
What the run did:
c is not a, the first letter, and there is no shorter border left to fall back to.
Question 5 of 15
Not this time.
You guessed: The pattern letter compared next is not the letter after the border, so fall back to a shorter border.
What the run did:
c is not a, the first letter, and there is no shorter border left to fall back to.
Question 5 of 15
Right.
You guessed: The pattern letter compared next is not its first letter, and no shorter border is left.
What the run did:
c is not a, the first letter, and there is no shorter border left to fall back to.
Question 6 of 15
Question 6 of 15
Right.
You guessed: Another letter is compared here, and it matches the pattern's.
What the run did:
The text's a at position 1 matches the pattern's a.
Question 6 of 15
Not this time.
You guessed: Another letter is compared here, and it is not the pattern's.
What the run did:
The text's a at position 1 matches the pattern's a.
Question 6 of 15
Not this time.
You guessed: No letter is left to compare, so the pattern stands here.
What the run did:
The text's a at position 1 matches the pattern's a.