next up previous
Next: Up: Previous:

Analysis



The Rabin-Karp algorithm takes $\Theta((n-m+1)m)$ time in the worst case.

O(n) + O(m(v + n/q)) average case, v = #valid shifts

If q $\geq$ m and v = O(1), then O(n+m).


next up previous
Next: Up: Previous: