The Complexity of Pattern Matching for a Random String

Andrew Chi-Chih Yao
1979 SIAM journal on computing (Print)  
We study the average-case complexity of finding all occurrences of a given pattern CX in an input text string. Over an alphabet of q symbols, let c&n) be the minimum average number of characters that need to be exa-mined in a-random text string of length n . We prove that, for large m , almost all patterns a of length m satisfy c&n) = Q(rlogq(E+2)1) if msnl2m, and c@,n) = 8 n m if n>2m. This in particular confirms a conjecture raised in a recent paper by Knuth, Morris, and Pratt [&I.
doi:10.1137/0208029 fatcat:akr6zxr7pndmfbn2eigbsn57fa