10.1145/359842.359859
Crossref journal-article
Association for Computing Machinery (ACM)
Communications of the ACM (320)
Abstract

An algorithm is presented that searches for the location, “ i l” of the first occurrence of a character string, “ pat ,” in another string, “ string .” During the search operation, the characters of pat are matched starting with the last character of pat . The information gained by starting the match at the end of the pattern often allows the algorithm to proceed in large jumps through the text being searched. Thus the algorithm has the unusual property that, in most cases, not all of the first i characters of string are inspected. The number of characters actually inspected (on the average) decreases as a function of the length of pat . For a random English pattern of length 5, the algorithm will typically inspect i /4 characters of string before finding a match at i . Furthermore, the algorithm has been implemented so that (on the average) fewer than i + patlen machine instructions are executed. These conclusions are supported with empirical evidence and a theoretical analysis of the average behavior of the algorithm. The worst case behavior of the algorithm is linear in i + patlen , assuming the availability of array space for tables linear in patlen plus the size of the alphabet.

Bibliography

Boyer, R. S., & Moore, J. S. (1977). A fast string searching algorithm. Communications of the ACM, 20(10), 762–772.

Authors 2
  1. Robert S. Boyer (first)
  2. J. Strother Moore (additional)
References 5 Referenced 1,523
  1. 10.1145/360825.360855
  2. {'volume-title': 'Mass.', 'year': '1972', 'author': 'Beeler M.', 'key': 'e_1_2_1_2_2'} / Mass. by Beeler M. (1972)
  3. {'key': 'e_1_2_1_3_2', 'first-page': '185', 'author': 'Dewey G.', 'year': '1923', 'journal-title': 'Mass.'} / Mass. by Dewey G. (1923)
  4. {'volume-title': 'Calif.', 'year': '1974', 'author': 'Knuth D.E.', 'key': 'e_1_2_1_4_2'} / Calif. by Knuth D.E. (1974)
  5. Knuth D.E. Morris J.H. and Pratt V.R. Fast pattern matching in strings. (to appear in SIAM J. Comput.). Knuth D.E. Morris J.H. and Pratt V.R. Fast pattern matching in strings. (to appear in SIAM J. Comput.).
Dates
Type When
Created 23 years, 1 month ago (July 27, 2002, 7:34 a.m.)
Deposited 2 months, 2 weeks ago (June 17, 2025, 12:38 p.m.)
Indexed 1 month ago (July 30, 2025, 11:10 a.m.)
Issued 47 years, 11 months ago (Oct. 1, 1977)
Published 47 years, 11 months ago (Oct. 1, 1977)
Published Online 47 years, 11 months ago (Oct. 1, 1977)
Published Print 47 years, 11 months ago (Oct. 1, 1977)
Funders 0

None

@article{Boyer_1977, title={A fast string searching algorithm}, volume={20}, ISSN={1557-7317}, url={http://dx.doi.org/10.1145/359842.359859}, DOI={10.1145/359842.359859}, number={10}, journal={Communications of the ACM}, publisher={Association for Computing Machinery (ACM)}, author={Boyer, Robert S. and Moore, J. Strother}, year={1977}, month=oct, pages={762–772} }