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 35
Question 1 of 27
Step 2 of 35
Step 3 of 35
Step 4 of 35
Step 5 of 35
Step 6 of 35
Step 7 of 35
Step 8 of 35
Step 9 of 35
Step 10 of 35
Step 11 of 35
Step 12 of 35
Question 1 of 27
Question 1 of 27
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 2 letters have a border one longer: 1.
Question 1 of 27
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 2 letters have a border one longer: 1.
Question 1 of 27
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 2 letters have a border one longer: 1.
Question 2 of 27
Question 2 of 27
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 1 letter long, so the first 3 letters have a border one longer: 2.
Question 2 of 27
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 1 letter long, so the first 3 letters have a border one longer: 2.
Question 2 of 27
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 1 letter long, so the first 3 letters have a border one longer: 2.
Question 3 of 27
Question 3 of 27
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 2 letters long, so the first 4 letters have a border one longer: 3.
Question 3 of 27
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 2 letters long, so the first 4 letters have a border one longer: 3.
Question 3 of 27
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 2 letters long, so the first 4 letters have a border one longer: 3.
Question 4 of 27
Question 4 of 27
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 3 letters long, so the first 5 letters have a border one longer: 4.
Question 4 of 27
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 3 letters long, so the first 5 letters have a border one longer: 4.
Question 4 of 27
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 3 letters long, so the first 5 letters have a border one longer: 4.
Question 5 of 27
Question 5 of 27
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 letter after a border 4 letters long. Fall back to that border's own border, 3 letters long, and compare again.
Question 5 of 27
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:
b is not a, the letter after a border 4 letters long. Fall back to that border's own border, 3 letters long, and compare again.
Question 5 of 27
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 is not a, the letter after a border 4 letters long. Fall back to that border's own border, 3 letters long, and compare again.
Question 6 of 27
Question 6 of 27
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 letter after a border 3 letters long. Fall back to that border's own border, 2 letters long, and compare again.
Question 6 of 27
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:
b is not a, the letter after a border 3 letters long. Fall back to that border's own border, 2 letters long, and compare again.
Question 6 of 27
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 is not a, the letter after a border 3 letters long. Fall back to that border's own border, 2 letters long, and compare again.