Advertisement

A Simple Fast Hybrid Pattern-Matching Algorithm

  • Frantisek Franek
  • Christopher G. Jennings
  • William F. Smyth
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3537)

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.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Boyer, R.S., Moore, J.S.: A fast string searching algorithm. Commun. Assoc. Comput. Mach. 20(10), 762–772 (1977)Google Scholar
  2. 2.
    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
  3. 3.
    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)Google Scholar
  4. 4.
    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)zbMATHCrossRefMathSciNetGoogle Scholar
  5. 5.
    Colussi, L.: Correctness and efficiency of pattern matching algorithms. Information & Computation 95, 225–251 (1991)zbMATHCrossRefMathSciNetGoogle Scholar
  6. 6.
    Colussi, L.: Fastest pattern matching in strings. J. Algs. 16(2), 163–189 (1994)zbMATHCrossRefMathSciNetGoogle Scholar
  7. 7.
    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)Google Scholar
  8. 8.
    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)zbMATHCrossRefMathSciNetGoogle Scholar
  9. 9.
    Crochemore, M., Hancart, C., Lecroq, T.: Algorithmique du Texte, Vuibert, Paris (2001)Google Scholar
  10. 10.
    Galil, Z., Giancarlo, R.: On the exact complexity of string matching: lower bounds. SIAM J. Comput. 20(6), 1008–1020 (1991)zbMATHCrossRefMathSciNetGoogle Scholar
  11. 11.
    Galil, Z., Giancarlo, R.: On the exact complexity of string matching: upper bounds. SIAM J. Comput. 21(3), 407–437 (1992)zbMATHCrossRefMathSciNetGoogle Scholar
  12. 12.
    Hart, M.: Project Gutenberg, Project Gutenberg Literary Archive Foundation (2004), http://www.gutenberg.net
  13. 13.
    Nigel Horspool, R.: Practical fast searching in strings. Software – Practice & Experience 10(6), 501–506 (1980)CrossRefGoogle Scholar
  14. 14.
    Hume, A., Sunday, D.: Fast string searching. Software – Practice & Experience 21(11), 1221–1248 (1991)CrossRefGoogle Scholar
  15. 15.
    Jennings, C.G.: A Linear-Time Algorithm for Fast Exact Pattern Matching in Strings. M. Sc. thesis, McMaster University, p. 97 (2002)Google Scholar
  16. 16.
    Knuth, D.E., Morris, J.H., Pratt, V.R.: Fast pattern matching in strings. SIAM J. Comput. 6(2), 323–350 (1977)zbMATHCrossRefMathSciNetGoogle Scholar
  17. 17.
    Lecroq, T.: Experimental results on string matching algorithms. Software – Practice & Experience 25(7), 727–765 (1995)CrossRefGoogle Scholar
  18. 18.
    Lecroq, T.: New Experimental Results on Exact String-Matching, Rapport LIFAR 2000.03, Université de Rouen (2000)Google Scholar
  19. 19.
    Morris, J.H., Pratt, V.R.: A Linear Pattern-Matching Algorithm. Tech. Rep. 40, University of California, Berkeley (1970)Google Scholar
  20. 20.
    Smyth, B.: Computing Patterns in Strings, p. 423. Pearson Addison-Wesley, London (2003)Google Scholar
  21. 21.
    Sunday, D.M.: A very fast substring search algorithm. Commun. Assoc. Comput. Mach. 33(8), 132–142 (1990)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Frantisek Franek
    • 1
  • Christopher G. Jennings
    • 2
  • William F. Smyth
    • 1
    • 3
  1. 1.Algorithms Research Group, Department of Computing & SoftwareMcMaster UniversityHamiltonCanada
  2. 2.School of Computing ScienceSimon Fraser UniversityBurnabyCanada
  3. 3.School of ComputingCurtin UniversityPerthAustralia

Personalised recommendations