The prior version of this section explained the algorithmic efficiency for a different variation of KMP. While the Big O notation stays the same, the iteration count is actually different, (k - 1) instead of (2k).
The complexity of the table algorithm is <code>O(k)</code>, where <code>k</code> is the length of <code>W</code>. As except for some initialization all the workThis is doneeasy into theprove, <code>'''while'''pos</code> loop, it is sufficientinitialized toas show that this loop executes in <code>O(k)</code> time1, which will be done by simultaneously examining the quantities <code>pos</code> and <code>pos - cnd</code>. In the firstloop branch, <code>pos - cnd</code>condition is preserved, as both <code>pos </code> and<code>cndk</code> are incremented simultaneously, but naturally,. <code>pos</code> is increased. In the second branch, <code>cnd</code> is replaced by <code>T[cnd]</code>,1 whichevery we saw [[#Efficiencyiteration of the search algorithm|above]] is always strictly less than <code>cnd</code>loop, thus increasingthe <code>posloop -will cnd</code>. Sincetake <code>pos ≥ posk - cnd1</code>,this means that at each stage either <code>pos</code> or a lower bound for <code>pos</code> increases; therefore since the algorithm terminates once <code>pos = k</code>iterations, itwhich mustcorresponds terminateto afteran atalgorithmic most <code>2k</code> iterationsefficiency of the loop, since <code>pos - cndO(k)</code> begins at <code>1</code>. Therefore,using the complexity[[Big ofO the table algorithm is <code>O(k)</code>notation]].