Abstract
We present bounds for the average case of the Knuth-Morris-Pratt (KMP) algorithm and the Boyer-Moore-Horspool (BMH) algorithm for random text. Experimental results in both random and English text suggests that the bounds are tight. We also present a hybrid algorithm which combines the KMP and BMH algorithms, and which, in practice, is faster than the Boyer-Moore algorithm.
This work was also supported by an Ontario Graduate Schoolarship, and the University of Chile, Santiago, Chile.
Preview
Unable to display preview. Download preview PDF.
References
A.V. Aho and M. Corasick. Efficient string matching: An aid to bibliographic search. C.ACM, 18(6):333–340, June 1975.
A. Apostolico and R. Giancarlo. The Boyer-Moore-Galil string searching strategies revisited. SIAM J on Computing, 15:98–105, 1986.
A.V. Aho. Pattern matching in strings. In R. Book, editor, Formal Language Theory: Perspectives and Open Problems, pages 325–347. Academic Press, London, 1980.
G. Barth. An alternative for the implementation of Knuth-Morris-Pratt algorithm. Inf. Proc. Letters, 13:134–137, 1981.
G. Barth. An analytical comparison of two string searching algorithms. Inf. Proc. Letters, 18:249–256, 1984.
R. Boyer and S. Moore. A fast string searching algorithm. C.ACM, 20:762–772, 1977.
R. Baeza-Yates. On the average case of string matching algorithms. Technical Report CS-87-66, Department of Computer Science, University of Waterloo, Ontario, Canada, 1987.
R. Baeza-Yates. Improved string searching. Software-Practice and Experience, 19(3):257–271, 1989.
R. Baeza-Yates and M. Regnier. Analysis of Boyer-Moore type string searching algorithms. (document in preparation), 1988.
A. Clausing. Kantorovich-type inequalities. The American Mathematical Monthly, 89:314–330, 1982.
D. Cox and H. Miller. The Theory of Stochastic Processes. Chapman and Hall, London, 1965.
B. Commentz-Walter. A string matching algorithm fast on the average. In ICALP, volume 6 of Lecture Notes in Computer Science, pages 118–132. Springer-Verlag, 1979.
G. Davies and S. Bowsher. Algorithms for pattern matching. Software — Practice and Experience, 16:575–601, 1986.
Z. Galil. On improving the worst case running time of the Boyer-Moore string matching algorithm. C.ACM, 22:505–508, 1979.
L. Guibas and A. Odlyzko. A new proof of the linearity of the Boyer-Moore string searching algorithm. SIAM J on Computing, 9:672–682, 1980.
N. Horspool. Practical fast searching in strings. Software — Practice and Experience, 10:501–506, 1980.
D.E. Knuth, J. Morris, and V. Pratt. Fast pattern matching in strings. SIAM J on Computing, 6:323–350, 1977.
B. Kernighan and D. Ritchie. The C Programming Language. Prentice-Hall, Englewood Cliffs, NJ, 1978.
M. Regnier. Knuth-Morris-Pratt algorithm: An analysis. INRIA, Rocquencourt, France (unpublished), 1988.
R. Rivest. On the worst-case behavior of string-searching algorithms. SIAM J on Computing, 6:669–674, 1977.
W. Rytter. A correct preprocessing algorithm for Boyer-Moore string-searching. SIAM J on Computing, 9:509–512, 1980.
R. Schaback. On the expected sublinearity of the Boyer-Moore algorithm. SIAM J on Computing, 17:548–658, 1988.
R. Sedgewick. Algorithms. Addison-Wesley, Reading, Mass., 1983.
G.V. Smit. A comparison of three string matching algorithms. Software — Practice and Experience, 12:57–66, 1982.
T. Takaoka. An on-line pattern matching algorithm. Inf. Proc. Letters, 22:329–330, 1986.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1989 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Baeza-Yates, R.A. (1989). String searching algorithms revisited. In: Dehne, F., Sack, J.R., Santoro, N. (eds) Algorithms and Data Structures. WADS 1989. Lecture Notes in Computer Science, vol 382. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-51542-9_9
Download citation
DOI: https://doi.org/10.1007/3-540-51542-9_9
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-51542-5
Online ISBN: 978-3-540-48237-6
eBook Packages: Springer Book Archive