KMP Match Algorithm

KMP Match Algorithm

j := 1; k := 1;

While j£T.Length And k£P.Length Do

If k = 0 Or T[j] = P[k] Then

j := j + 1; k := k + 1;

Else

k := fail[k];

End If

End While;

If k>P.length Then

Return True;

Else

Return False;

End If

Previous slide Back to the first slide View Graphic Version