Abstract
The Knuth-Morris-Pratt (KMP) pattern-matching algorithm guarantees both independence from alphabet size and worst-case execution time linear in the pattern length; on the other hand, the Boyer-Moore (BM) algorithm provides near-optimal average-case and best-case behaviour, as well as executing very fast in practice. We describe a simple algorithm that employs the main ideas of KMP and BM (with a little help from Sunday) in an effort to combine these desirable features. Experiments indicate that in practice the new algorithm is among the fastest exact pattern-matching algorithms discovered to date, perhaps dominant for alphabet size 8 or more.
Supported in part by grants from the Natural Sciences & Engineering Research Council of Canada.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Boyer, R.S., Moore, J.S.: A fast string searching algorithm. Commun. Assoc. Comput. Mach. 20(10), 762–772 (1977)
Charras, C., Lecroq, T.: Exact String Matching Algorithms, Laboratoire d’Informatique, Université de Rouen (1997), http://www-igm.univ-mlv.fr/~lecroq/string/index.html
Cole, R., Hariharan, R.: Tighter bounds on the exact complexity of string matching. In: Proc. 33rd IEEE Symp. Found. Comp. Sci., pp. 600–609 (1992)
Cole, R., Hariharan, R., Paterson, M.S., Zwick, U.: Tighter lower bounds on the exact complexity of string matching. SIAM J. Comput. 24(1), 30–45 (1995)
Colussi, L.: Correctness and efficiency of pattern matching algorithms. Information & Computation 95, 225–251 (1991)
Colussi, L.: Fastest pattern matching in strings. J. Algs. 16(2), 163–189 (1994)
Colussi, L., Galil, Z., Giancarlo, R.: On the exact complexity of string matching. In: Proc. 31st IEEE Symp. Found. Comp. Sci., vol. I, pp. 135–143 (1990)
Crochemore, M., Czumaj, A., Ga̧sieniec, L., Jarominek, S., Lecroq, T., Plandowski, W., Rytter, W.: Speeding up two stringmatching algorithms. Algorithmica 12, 247–267 (1994)
Crochemore, M., Hancart, C., Lecroq, T.: Algorithmique du Texte, Vuibert, Paris (2001)
Galil, Z., Giancarlo, R.: On the exact complexity of string matching: lower bounds. SIAM J. Comput. 20(6), 1008–1020 (1991)
Galil, Z., Giancarlo, R.: On the exact complexity of string matching: upper bounds. SIAM J. Comput. 21(3), 407–437 (1992)
Hart, M.: Project Gutenberg, Project Gutenberg Literary Archive Foundation (2004), http://www.gutenberg.net
Nigel Horspool, R.: Practical fast searching in strings. Software – Practice & Experience 10(6), 501–506 (1980)
Hume, A., Sunday, D.: Fast string searching. Software – Practice & Experience 21(11), 1221–1248 (1991)
Jennings, C.G.: A Linear-Time Algorithm for Fast Exact Pattern Matching in Strings. M. Sc. thesis, McMaster University, p. 97 (2002)
Knuth, D.E., Morris, J.H., Pratt, V.R.: Fast pattern matching in strings. SIAM J. Comput. 6(2), 323–350 (1977)
Lecroq, T.: Experimental results on string matching algorithms. Software – Practice & Experience 25(7), 727–765 (1995)
Lecroq, T.: New Experimental Results on Exact String-Matching, Rapport LIFAR 2000.03, Université de Rouen (2000)
Morris, J.H., Pratt, V.R.: A Linear Pattern-Matching Algorithm. Tech. Rep. 40, University of California, Berkeley (1970)
Smyth, B.: Computing Patterns in Strings, p. 423. Pearson Addison-Wesley, London (2003)
Sunday, D.M.: A very fast substring search algorithm. Commun. Assoc. Comput. Mach. 33(8), 132–142 (1990)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2005 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Franek, F., Jennings, C.G., Smyth, W.F. (2005). A Simple Fast Hybrid Pattern-Matching Algorithm. In: Apostolico, A., Crochemore, M., Park, K. (eds) Combinatorial Pattern Matching. CPM 2005. Lecture Notes in Computer Science, vol 3537. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11496656_25
Download citation
DOI: https://doi.org/10.1007/11496656_25
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-26201-5
Online ISBN: 978-3-540-31562-9
eBook Packages: Computer ScienceComputer Science (R0)