Bad-Character Heuristic

In the case of a mismatch, $P[j] \ne T[s+j]$:

Look for the occurrence of mismatch character in the pattern, such that P[k]=T[s+j].

Three cases:

k=0: The character occurs nowhere in the pattern

aaac........
aaaaaa
    aaaaaa

k<j: The rightmost occurrence of the bad character is to the left of j

aaacaa........
acaaaa
  acaaaa

k>j: The rightmost occurrence of the bad character is to the right of j

..aaacac........
  aaaaac
aaaaac


next up previous
Next: Bad-Character Heuristic Analysis Up: BOYER-MOORE Previous: Boyer-Moore Algorithm