FAST STRING SEARCHING ALGORITHM
FAST STRING SEARCHING ALGORITHM
复制标题
DOI:
10.1145/359842.359859
复制
发表时间:
1977-01-01
影响因子:
22.7
通讯作者:
MOORE, JS
中科院分区:
文献类型:
--
作者:
BOYER, RS;MOORE, JS
An algorithm is presented that searches for the location, “il” of the first occurrence of a character string, “pat,” in another string, “string.” During the search operation, the characters ofpatare matched starting with the last character ofpat. 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 firsticharacters ofstringare inspected. The number of characters actually inspected (on the average) decreases as a function of the length ofpat. For a random English pattern of length 5, the algorithm will typically inspecti/4 characters ofstringbefore finding a match ati. Furthermore, the algorithm has been implemented so that (on the average) fewer thani+patlenmachine 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 ini+patlen, assuming the availability of array space for tables linear inpatlenplus the size of the alphabet.