Why it matters

Boyer-Moore is fastest practical matcher. Understanding shapes text tools.

Advertisement

The architecture

Right-to-left comparison.

Bad character rule: shift by mismatch char position.

Good suffix rule: use matched suffix info.

Boyer-Moore rulesRight-to-left comparefrom pattern endBad char shifton mismatchGood suffix shiftmatched suffixBoyer-Moore-Horspool simplified variant popular; grep uses BM variants
Boyer-Moore.
Advertisement

How it works end to end

Preprocess: bad char table + good suffix table.

Skip potentially many characters.

Best case O(n/m).

Worst O(nm) rare.