Upload
yudhitya-syahputra-lubis
View
213
Download
0
Embed Size (px)
Citation preview
1
Turbo-BM Algorithm
Adviser: R. C. T. Lee
Speaker: H. M. Chen
Deux méthodes pour accélérer l'algorithme de Boyer-Moore,
Théorie des Automates et Applications. ,
589-600, 1992.
CROCHEMORE, M., CZUMAJ, A., GASIENIEC, L.,
JAROMINEK, S., LECROQ, T., PLANDOWSKI, W. and
RYTTER, W.
Turbo BM
2
3
•The Turbo-BM algorithm is an amelioration of the
Boyer-Moore algorithm.
•It needs no extra preprocessing and requires only a
constant extra space with respect to the original Boyer-
Moore algorithm.
•It improves the worst-case complexity of Boyer-Moore
algorithm.
Turbo-BM
4
S1
S1Text
Pattern
S1
S1Text
Pattern S1
S1
S1Text
Pattern S1
Good Suffix Rule 1 of the BM Algorithm.
5
S2
S2Text
Pattern
Another matching:
S1
S1
But, remember that S1 is a suffix of P.
S2
S2Text
Pattern S1
S1
Thus,
S2
S2Text
Pattern S2
S2
S1
S1
S1 S1
6
S2
S1
Text
Pattern
S2y
x
S2x
S1
S2x
S2
S2Text
Pattern S2
S2
S1S1
S1
S1
7
If we move only one step
S2
S1
Text
Pattern
S2y
x
S2x
S2x y
After this one step move
S2
S1
Text
Pattern
S2y
x
S2x
S1
S2x y
y
S1
y
S1
For a successful
matching.
Impossible for matching.
8
Conclude :
We must move at least |S1| - | S2| steps.
Condition :
(1) In the pervious step, Good Suffix Rule 1 (BM) was used.
Thus S1 is long and not unique. This means that there is
a period.
(2)In the pervious step, S2 is contained in S1.
S1
S2
S1
9
We compare the pattern and the text from right to left. Turbo-BM skips the memory part which has been matched in preceding attempt.
Text =
Pattern =
memory
match
Turbo-skip
10
b b a a b b b b b b a b a b a b a a a b a b a b
b b a b a b a b a a a b a b a b
Text =
Pattern =
b b a a b b b b b b a b a b a b a a a b a b a b
b b a b a b a b a a a b a b a b
Text =
Pattern =
Example
memory
match
11
b b a a b c a b a c c a a d a b a a b a a a d a
b b a b a a a b a
Text =
Pattern =
b b a b a a a b a
Shift by using Good Suffix Rule 1
Full Example
memory
12
b b a a b c a b a c c a a d a b a a b a a a d aText =
Pattern = b b a b a a a b amemory
b b a b a a a b a Turbo-shift= |aba| - |a| = 2
Shift by Turbo-shift
b b a a b c a b a c c a a d a b a a b a a a d aText =
Pattern = b b a b a a a b a
Shift by Good Suffix Rule 1
b b a b a a a b a
We select the maximal number of shift between Good Suffix Rule 1
and Turbo-shift.
Full Example
13
b b a a b c a b a c c a a d a b a a b a a a d aText =
Pattern = b b a b a a a b a
b b a b a a a b amemory
Shift by using Good Suffix Rule 1
Full Example
14
b b a a b c a b a c c a a d a b a b b a b a a aText =
Pattern = b b a b a a a b amemory
match is aba, but memory is a. when |match| > |memory|, we shift pattern
by using Good Suffix Rule 1 only.
Turbo-skip
b b a a b c a b a c c a a d a b a b b a b a a aText =
Pattern = b b a b a a a b a
b b a b a a a b a
Shift by Good Suffix Rule 1
Full Example
15
• The preprocessing phase in O(m+Σ) time and
space complexity and searching phase in O(n)
time complexity.
Time Complexity
16
References
• Off-line serial exact string searching , CROCHEMORE, M. , Oxford University Press , Chapter 1 , 1997 , pp. 1-53.
• Deux méthodes pour accélérer l'algorithme de Boyer-Moore , CROCHEMORE, M. , CZUMAJ, A. , GASIENIEC, L. , JAROMINEK, S. , LECROQ, T. , PLANDOWSKI, W. and RYTTER W. , Rouen France , 1991, pp. 45-63.
• Speeding up two string matching algorithms , CROCHEMORE, M. , CZUMAJ, A. , GASIENIEC, L. , JAROMINEK, S. , LECROQ, T. , PLANDOWSKI, W. and RYTTER, W. , Algorithmica , Vol 12 , 1994 , pp. 247-267.
• Text Algorithms , CROCHEMORE, M. and RYTTER, W. , Oxford University Press , 1994.
• Recherches de mot , LECROQ, T. , University of Orléans, France , 1992.
• Experimental results on string matching algorithms , LECROQ, T. , Software - Practice & Experience , Vol 25 , 1995 , pp.727-765.
17
THANK YOU