$./mp-search
text:
pattern:
2 step/s
# algorithm
1MP(t, p) {n = |t|, m = |p|}
2begin
3 ij1
4 while jn do
5 while (i = m + 1) or (i > 0 and p[i]t[j]) do iMPnext[i]
6 ii + 1; jj + 1
7 if i = m + 1 then Output(ji + 1)
8 od
9end
# text t (1-indexed)
no data
# pattern p (1-indexed)
no data
# variables
i
j
n
20
m
6
t[j]
p[i]
# MPNext array (precomputed)
no data
# matches found
no data
# current action
enter text and pattern, then click "run" to begin...