Title: Reverse Factor Algorithm
1Reverse Factor Algorithm
Speeding up on two string matching algorithms,
Algorithmica, Vol.12, 1994, pp.247-267 CROCHEMORE,
M., CZUMAJ, A., GASIENIEC, L., JAROMINEK, S.,
LECROQ, T., PLANDOWSKI, W. and RYTTER, W.
- Advisor Prof. R. C. T. Lee
- Speaker L. C. Chen
2Rule 1 The Suffix to Prefix Rule
- For a window to have any chance to match a
pattern, in some way, there must be a suffix of
the window which is equal to a prefix of the
pattern.
3Basic Ideas
- Open a window W with size P in the text.
-
W
T
P
p
- Find the longest suffix of W is also the prefix
of pattern.
Case 1
W
T
P
p
Match!
4Case 2
W
T
P
p
W
T
P
p
Case 3
If there is no such suffix, we move W with length
P.
W
T
P
P
p
5Preprocessing phase
- TGCATCGGCGAGAGTATACAGTACGÂ
- PGCAGAGAG
- L(S) a set contains all prefixes of the pattern.
We construct the suffix automaton of P.
C
Suffix Automaton
A
G
G
A
C
G
G
A
0
8
7
6
5
4
3
2
1
C
A
C
6Preprocessing Construct a Suffix Tree
PR the reversal string of P.
1
2
4
7
3
8
6
5
7When there is a match, how do we move the window?
T
P
8T
P
9 Find the longest suffix of W is also the prefix
of pattern.
T
P
10T
P
11A Whole Example
- TGCATCGCAGAGAGTATACAGTACGÂ
- PGCAGAGAG
- First attempt Â
T
P
Shift by 5 (8 - 3)
12Second attempt
T
P
Shift by 7 (8 - 1)
13Third attempt
T
P
Shift by 7 (8 - 1)
14Third attempt
T
P
15Conclusion
- Preprocessing phase is O(m).
- Searching phase is O(mn).
16Reference
- A90Algorithms for finding patterns in strings,
A. V. Aho, Handbook of Theoretical Computer
Science, Vol. A, Elsevier, Amsterdam, 1990,
pp.255-300. - A85The myriad virtues of suffix trees,
Apostolico, A., Combinatorial Algorithms on
words, NATO Advanced Science Institutes, Series
F, Vol. 12, 1985, pp.85-96 - AG86The Boyer-Moore-Galil string searching
strategies revisited, Apostolico, A. and
Giancarlo, R., SIAM, Comput. 15, 1986, pp98-105. - BR92Average running time of the
Boyer-Moore-Horspool algorithm, Baeza-Yates, R.
A. and Regnier, M. Theoret. Comput. Sci., 1992,
pp.19-31. - BKR91Analysis of algorithms and Data
Structures, Banachowski, L., Kreczmar, A. and
Rytter, W., Addison-Wesley. Reading, MA,1991.