Beruflich Dokumente
Kultur Dokumente
Adviser: R. C. T. Lee
Speaker: H. M. Chen
Turbo BM
Turbo-BM
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 BoyerMoore algorithm.
It improves the worst-case complexity of Boyer-Moore
algorithm.
3
S1
Pattern
S1
Text
S1
Pattern
S1
Text
S1
S1
Pattern
S1
S1
4
Another matching:
Text
S1
S2
Pattern
S1
S2
S1
S2
Pattern
S1
S2
S1
Thus,
Text
S2
S2
S2
S2
S1
Pattern
S1
S1
Text
S2
S2
S2
S2
S1
Pattern
S1
S1
S1
x
Text
Pattern
S1
x
S2
S2
S2
S1
x
S2
For a successful
matching.
Text
Pattern
Pattern
x
S1
S1
x
S2
y
S2
S2
x
S1
S2
S2
x
S1
S2
S2
S2
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
Turbo-skip
We compare the pattern and the text from right to left.
Turbo-BM skips the memory part which has been
matched in preceding attempt.
match
memory
Text =
Pattern =
Example
Text =
Pattern =
bbaabbbbbbabababaaababab
bbabababaaababab
match
Text =
bbaabbbbbbabababaaababab
Pattern =
bbabababaaababab
memory
10
Full Example
Text =
bbaabcabaccaadabaabaaada
Pattern = b b a b a a a b a
bbabaaaba
memory
11
Full Example
Shift by Turbo-shift
Text = b b a a b c a b a c c a a d a b a a b a a a d a
Pattern =
bbabaaaba
memory
bbabaaaba
Text =
Pattern =
bbaabcabaccaadabaabaaada
bbaba aaba
bbaba aaba
Full Example
Text =
Pattern =
bbaabcabaccaadabaabaaada
bbabaaaba
bbabaaaba
memory
13
Full Example
Text =
Pattern =
Turbo-skip
bbaabcabaccaadababbabaaa
bbabaaaba
memory
match is aba, but memory is a. when |match| > |memory|, we shift pattern
by using Good Suffix Rule 1 only.
Text =
Pattern =
bbaabcabaccaadababbabaaa
bbaba aaba
bbabaaaba
Shift by Good Suffix Rule 1
14
Time Complexity
The preprocessing phase in O(m+) time and
space complexity and searching phase in O(n)
time complexity.
15
References
16
THANK YOU
17