2
Problem Definition Input: a text string T with length n and a pattern string P with length m. Output: all occurrences of P in T.

3
Definition T s : the first character of a string T aligns to a pattern P. P l : the first character of a pattern P aligns to a string T. T j : the character of the jth position of a string T. P i : the character of the ith position of a pattern P. P f : the last character of a pattern P. n : The length of T. m : The length of P.

6
Tuned Boyer Moore Algorithm In this algorithm, We always focus on the last character of the window of T and try to slide the pattern to match the last character of T.

7
Tuned Boyer Moore Algorithm Rule Txzy Since T s+m-1 P f, we move the pattern P to right such that the largest position i in the right of P i is equal to T s+m. We can shift the pattern at least (m-i) positions right until T s+m-1 = P f. Shift ss+m-1 Pzxy i1f Pzxy i 1 f Pzxy i 1 f Shift

8
Tuned Boyer Moore Preprocessing Table In this algorithm, we construct a table as follow. Let x be a character in the alphabet. We record the position of the last x, if it exists in P, we record the position of x from the second last position of P. If x does not exist in P 1 to P m-1, we record it as m.