On the Exact Complexity of String Matching: Upper Bounds
Authors:
- Zvi GalilZGZvi Galil
- Raffaele GiancarloRGRaffaele Giancarlo
- 1 June 1992
- journal article
- Published by Society for Industrial & Applied Mathematics (SIAM) in SIAM Journal on Computing
- Vol. 21 (3) , 407-437
Abstract
It is shown that, for any pattern of length m and for any text of length n, it is possible to find all occurrences of the pattern in the text in overall linear time and at most $\frac{4}{3}n - \frac{1}{3}m$ character comparisons. In fact, the bound on the number of character comparisons is usually tighter than this, for the bound is expressed in terms of the structure of the pattern. The algorithm here need not have any knowledge of the alphabet. This improves the best previous bound of $1.5n-.5(m - 1)$ obtained by Colussi [Inform. and Comput., to appear] and Apostolico and Crochemore [Tech. Report TR89-75, LITP, Université de Paris, Paris, France, 1989]. In a companion paper [SIAM J. Comput., 20 (1991), pp. 1008–1020], the authors show a lower bound for on-line algorithms that is equal to $\frac{4}{3}n - \frac{1}{3}m$ for $m = 3$. For $m = 1,2,n$ character comparisons is optimal. This algorithm is based on a new analysis of the string matching algorithm by Colussi. Moreover, this new analysis of Colussi’s algorithm confirms the experimental results showing that his algorithm performs very well in practice [Inform. and Comput., to appear].
Keywords
This publication has 15 references indexed in Scilit:
- On the Exact Complexity of String Matching: Lower BoundsSIAM Journal on Computing, 1991
- Correctness and efficiency of pattern matching algorithmsInformation and Computation, 1991
- The Boyer–Moore–Galil String Searching Strategies RevisitedSIAM Journal on Computing, 1986
- A Unified Lower Bound for Selection and Set Partitioning ProblemsJournal of the ACM, 1981
- A New Proof of the Linearity of the Boyer-Moore String Searching AlgorithmSIAM Journal on Computing, 1980
- On improving the worst case running time of the Boyer-Moore string matching algorithmCommunications of the ACM, 1979
- A fast string searching algorithmCommunications of the ACM, 1977
- Fast Pattern Matching in StringsSIAM Journal on Computing, 1977
- The equation $a^M=b^Nc^P$ in a free group.The Michigan Mathematical Journal, 1962
- A Tournament ProblemThe American Mathematical Monthly, 1959