A very fast string matching algorithm for small alphabets and long patterns
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.
KeywordsString Match Search Phase Preprocessing Phase String Match Algorithm Symbol Comparison
Unable to display preview. Download preview PDF.
- R. S. Boyer and J. S. Moore. A fast string searching algorithm. Comm. ACM, 20(10):762–772,1977.Google Scholar
- 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.Google Scholar
- M. Crochemore and W. Rytter. Text algorithms. Oxford University Press, 1994.Google Scholar
- A. Hume and D. M. Sunday. Fast string searching. Software-Practice Experience, 21 (11):1221–1248, 1991.Google Scholar
- D. E. Knuth, J. H. Morris, Jr, and V. R. Pratt. Fast pattern matching in strings. SIAM J. Comput., 6(1):323–350, 1977.Google Scholar
- T. Lecroq. A variation on the Boyer-Moore algorithm. Theoret. Comput. Sci., 92(l):119–144,1992.Google Scholar
- T. Lecroq. Experiments on string matching in memory structures. Software-Practice & Experience, 28(5):562–568, 1998.Google Scholar
- J. H. Morris, Jr and V. R. Pratt. A linear pattern-matching algorithm. Report 40, University of California, Berkeley, 1970.Google Scholar
- T. Raita. Tuning the Boyer-Moore-Horspool string searching algorithm. Software-Practice & Experience, 22(10):879–884, 1992.Google Scholar
- G. A. Stephen. String searching algorithms. World Scientific Press, 1994.Google Scholar