# Fast Pattern Matching in Strings

@article{Knuth1977FastPM, title={Fast Pattern Matching in Strings}, author={Donald Ervin Knuth and James H. Morris and Vaughan R. Pratt}, journal={SIAM J. Comput.}, year={1977}, volume={6}, pages={323-350} }

An algorithm is presented which finds all occurrences of one given string within another, in running time proportional to the sum of the lengths of the strings. The constant of proportionality is low enough to make this algorithm of practical use, and the procedure can also be extended to deal with some more general pattern-matching problems. A theoretical application of the algorithm shows that the set of concatenations of even palindromes, i.e., the language $\{\alpha \alpha ^R\}^*$, can be…

## Tables from this paper

## 3,015 Citations

### On the Worst-Case Behavior of String-Searching Algorithms

- Computer Science, MathematicsSIAM J. Comput.
- 1977

There do not exist pattern matching algorithms whose worst-case behavior is “sublinear” in n (that is, linear with constant less than one), in contrast with the situation for average behavior (the Boyer-Moore algorithm is known to be sublinear on the average).

### Efficient Comparison Based String Matching

- Computer ScienceJ. Complex.
- 1993

This work gives a linear-time algorithm that finds all occurrences of a pattern of length m in a text of length n in [formula] comparisons and establishes that, in general, searching for a long pattern is easier than searched for a short one.

### Matching Patterns in Strings Subject to Multi-Linear Transformations

- Computer Science, MathematicsTheor. Comput. Sci.
- 1988

### Efficient String Matching with Don’t-Care Patterns

- Computer Science
- 1985

This paper considers the extension of the methods of Aho and Corasick to deal with patterns involving more expressive descriptions, such as don’t-care (wild-card) symbols, complements, etc.

### Efficient Randomized Pattern-Matching Algorithms

- Computer Science, MathematicsIBM J. Res. Dev.
- 1987

We present randomized algorithms to solve the following string-matching problem and some of its generalizations: Given a string X of length n (the pattern) and a string Y (the text), find the first…

### Discovering Repetitions in Strings

- Computer Science
- 1985

The basic problem is to determine whether a pattern string x appears as a (contiguous) substring of a text y, i.e. whether for some strings u, v, the authors have y= uxv.

### Fast Packed String Matching for Short Patterns

- Computer ScienceALENEX
- 2013

Specialized word-size packed string matching instructions, based on the Intel streaming SIMD extensions (SSE) technology, are used to design very fast string matching algorithms in the case of short patterns.

### Fast Searching in Packed Strings

- Computer Science, MathematicsCPM
- 2009

This paper studies the worst-case complexity of string matching on strings given in packed representation on the basis of classical Knuth-Morris-Pratt algorithm.

## References

SHOWING 1-10 OF 28 REFERENCES

### STRING-MATCHING AND OTHER PRODUCTS

- Computer Science
- 1974

By exploiting the formal similarity of string-matching with integer multiplication, a new algorithm has been obtained with a running time which is only slightly worse than linear.

### Rapid identification of repeated patterns in strings, trees and arrays

- Computer Science, MathematicsSTOC
- 1972

This paper describes a strategy for constructing efficient algorithms for solving two types of matching problems and develops explicit algorithms for these two problems applied to strings and arrays.

### A New Linear-Time ``On-Line'' Algorithm for Finding the Smallest Initial Palindrome of a String

- Computer ScienceJACM
- 1975

The present algorithm, based on the Knuth-Morris-Prat algorithm, solves the problem of recognizing the initial leftmost nonvoid palindrome of a string in time proportional to the length N of thePalindrome, and an extension allows one to recognize the initial odd or even palindromes of length 2 or greater.

### Implementation of the substring test by hashing

- Computer ScienceCACM
- 1971

Tradeoff curves are developed to show minimal cost of file usage by grouping various partially combined indices under conditions offile usage with different fractions of retrieval and update.

### The Design and Analysis of Computer Algorithms

- Computer Science
- 1974

This text introduces the basic data structures and programming techniques often used in efficient algorithms, and covers use of lists, push-down stacks, queues, trees, and graphs.

### A fast string searching algorithm

- Computer ScienceCACM
- 1977

The algorithm has the unusual property that, in most cases, not all of the first <italic>i</italic) characters of a character string, “<italic>.” in another string, are inspected.

### On converting on-line algorithms into real-time and on real-time algorithms for string-matching and palindrome recognition

- Computer ScienceSIGA
- 1975

This work uses a sufficient condition when an on-line algorithm can be transformed into a real-time algorithm to construct real- time algorithms for string-matching and palindrome recognition problems by random access machines and by Turing machines.

### Synchronization of binary messages

- Computer ScienceIRE Trans. Inf. Theory
- 1960

If blocks of N digits are used, the prefix should be chosen to make large the number G(N) of different blocks which satisfy the constraints, and strengthening the prefix decreases the number of "message digits" which remain in the block but also relaxes the constraints.

### On the Translation of Languages from Left to Right

- Computer Science, LinguisticsInf. Control.
- 1965

### Structured Programming with go to Statements

- Computer ScienceCSUR
- 1974

For serious students of structured programming, and also for language designers, Knuth's "Structured Programming with go to Statements" is probably the paper to read. It is by far the most complete…