On the Worst-Case Behavior of String-Searching Algorithms
Author:
- Ronald L. RivestRRRonald L. Rivest
- 1 December 1977
- journal article
- Published by Society for Industrial & Applied Mathematics (SIAM) in SIAM Journal on Computing
- Vol. 6 (4) , 669-674
Abstract
Any algorithm for finding a pattern of length k in a string of length n must examine at least $n - k + 1$ of the characters of the string in the worst case. By considering the pattern $00 \cdots 0$, we prove that this is the best possible result. Therefore 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).
Keywords
This publication has 3 references indexed in Scilit:
- Fast Pattern Matching in StringsSIAM Journal on Computing, 1977
- Efficient string matchingCommunications of the ACM, 1975
- A generalization and proof of the Aanderaa-Rosenberg conjecture1975