Boyer Moore string matching

111 Views Asked by At

If I had the pattern = abc and the string: aabcbcbabcabcabc.

Using the Boyer Moore algorithm in order to do string comparison, would you shift by one to the right if you get one match. I'll show my working so far:

aabcbcbabcabcabc
abc 

1) so c doesn't match 2) b doesn't match 3) but a matches (would we shift one down here) so your next comparison would be:

aabcbcbabcabcabc
 abc 

4) Then we have c matching 5) b matches 6) a matches

Coming to a total of just 6 matches in order to get find the pattern in the string.