摘要: This paper deals with an average analysis of the Knuth-Morris-Pratt algorithm. Searching all occurrences a given pattern p in text length n implies cp.n text-pattern comparisons. Averaging over patterns yields cost c.n. The constant linearity c is derived. In particular, when cardinality q alphabet large, it proven that ∼ 1+1/q. An algebraic scheme used, based on combinatorics words and generating functions.