Abstract: The tradition pattern matching algorithm need backtrack and compare repeatedly, so that affects efficiency of algorithm. Knuth and others put forward KMP algorithm in order to promote ...
Scenario 1: random text, random pattern With a 26-character alphabet, the chance of a partial match at any given position is low, so naive rarely has to backtrack far before giving up and moving on.