Knuth–Morris–Pratt algorithm: Difference between revisions

Content deleted Content added
Almi (talk | contribs)
No edit summary
Almi (talk | contribs)
No edit summary
Line 1:
'''Knuth-Morris-Pratt Algorithm'''
This algorithm uses the fact that after finding the first mismatch, we already know the characters compared before. We therefore will have to compare the pattern to itself to determine how many positions we have to move to the left.
 
 
INPUT: Text T[0,n-1], Pattern P[0,m-1]
Line 22 ⟶ 23:
}
 
 
Procedure InitNext(P)
Input: Pattern P