BM(t, p) {n = |t|, m = |p|}begin pos ← 1 while pos ≤ n − m + 1 do i ← m while i > 0 and p[i] = t[pos + i − 1] do i ← i − 1 if i = 0 then Output(pos) pos ← pos + D[i] odendBoyer-Moore compares the pattern from right to left (i starts at m).
When a mismatch occurs at position i in the pattern, it shifts by D[i] positions.
The D array (good suffix shift) allows skipping positions that cannot match, making the algorithm very efficient in practice.