Boyer-Moore — Right-to-Left Scan with Bad-Character & Good-Suffix Shifts
Align the pattern under the text, scan right → left. On a mismatch, see the bad-character and good-suffix shift candidates and watch the pattern jump by the chosen (maximum) shift.
step 0
Alignment & right-to-left scan
Bad-character shift
—
align the mismatched text char with its last occurrence in P
Good-suffix shift
—
re-align the matched suffix with another copy / prefix
Chosen = max
—
the larger safe jump finishes the search faster
current window matched (right→left) bad character
matches: (none yet)
Precomputed last-occurrence table
Press Step to begin. Boyer-Moore aligns the pattern under the text and compares from the right end first, jumping forward by the larger of two precomputed shifts on each mismatch.
Self-contained visualization of the full Boyer-Moore algorithm (bad-character + good-suffix, max shift).
A shift is always clamped to at least 1. After a full match the pattern advances by the good-suffix continue-shift so overlapping occurrences are not missed.
See junior.md and professional.md for the proof that neither shift rule ever skips a real occurrence.