A simple fast hybrid pattern-matching algorithm

  • Authors:
  • Frantisek Franek;Christopher G. Jennings;W. F. Smyth

  • Affiliations:
  • Algorithms Research Group, Department of Computing & Software, McMaster University, Hamilton ON L8S 4K1, Canada;School of Computing Science, Simon Fraser University, 8888 University Drive, Burnaby BC V5A 1S6, Canada;Algorithms Research Group, Department of Computing & Software, McMaster University, Hamilton ON L8S 4K1, Canada and School of Computing, Curtin University, GPO Box U1987, Perth WA 6845, Australia

  • Venue:
  • Journal of Discrete Algorithms
  • Year:
  • 2007

Quantified Score

Hi-index 0.00

Visualization

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, apparently dominant for alphabet size above 15-20.