Abstract
We are interested in the exact string matching problem which consists of searching for all the occurrences of a pattern of length m in a text of length n. Both the pattern and the text are built over an alphabet Σ of size σ. We present three versions of an exact string matching algorithm. They use a new shifting technique. The first version is straightforward and easy to implement. The second version is linear in the worst case, an improvement over the first. The main result is the third algorithm. It is very fast in practice for small alphabet and long patterns. Asymptotically, it performs O(logσ m(m + n/(m - logσ, m))) inspections of text symbols in the average case. This compares favorably with many other string searching algorithms.
The work of these authors was partially supported by the project “Informatique et Génomes” of the french CNRS.
Preview
Unable to display preview. Download preview PDF.
References
R. S. Boyer and J. S. Moore. A fast string searching algorithm. Comm. ACM, 20(10):762–772,1977.
M. Crochemore, A. Czumaj, L. Gćasieniec, S. Jarominek, T. Lecroq, W. Plandowski, and W. Rytter. Speeding up two string matching algorithms. Algorithmica, 12(4/5):247–267, 1994.
M. Crochemore and W. Rytter. Text algorithms. Oxford University Press, 1994.
A. Hume and D. M. Sunday. Fast string searching. Software-Practice Experience, 21 (11):1221–1248, 1991.
D. E. Knuth, J. H. Morris, Jr, and V. R. Pratt. Fast pattern matching in strings. SIAM J. Comput., 6(1):323–350, 1977.
T. Lecroq. A variation on the Boyer-Moore algorithm. Theoret. Comput. Sci., 92(l):119–144,1992.
T. Lecroq. Experiments on string matching in memory structures. Software-Practice & Experience, 28(5):562–568, 1998.
J. H. Morris, Jr and V. R. Pratt. A linear pattern-matching algorithm. Report 40, University of California, Berkeley, 1970.
T. Raita. Tuning the Boyer-Moore-Horspool string searching algorithm. Software-Practice & Experience, 22(10):879–884, 1992.
G. A. Stephen. String searching algorithms. World Scientific Press, 1994.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1998 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Charras, C., Lecrog, T., Pehoushek, J.D. (1998). A very fast string matching algorithm for small alphabets and long patterns. In: Farach-Colton, M. (eds) Combinatorial Pattern Matching. CPM 1998. Lecture Notes in Computer Science, vol 1448. Springer, Berlin, Heidelberg. https://doi.org/10.1007/BFb0030780
Download citation
DOI: https://doi.org/10.1007/BFb0030780
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-64739-3
Online ISBN: 978-3-540-69054-2
eBook Packages: Springer Book Archive