KMP Matcher Algorithm
KMP Matcher Algorithm
Following pseudocode computes the prefix fucnction, : Compute-Prefix-Function (p) 1 m length[p] //p pattern to be matched 2 [1] 0 3 k0 4 for q 2 to m 5 do while k > 0 and p[k+1] != p[q] 6 do k [k] 7 If p[k+1] = p[q] 8 then k k +1 9 [q] k 10 return