Hi,
I've been looking at the KMP example on pg 335 in Chapter 6 of CP4 book 2.
I noticed that in the examples you seem to preprocess a table that is pattern size + 1,
so that the kmpSearch can reset correctly once a match is found (j = b[j])
However the kmpPreprocess function seems to only iterate for i < m.
Assuming m is the size of the pattern string we won't fully fill out the table,
should the preprocessing iterate for i <= m ? Or is m here the size of the pattern+1?
Or maybe I am misunderstanding something. Any clarification is appreciated!
Hi, I've been looking at the KMP example on pg 335 in Chapter 6 of CP4 book 2. I noticed that in the examples you seem to preprocess a table that is pattern size + 1, so that the
kmpSearch
can reset correctly once a match is found (j = b[j]
) However thekmpPreprocess
function seems to only iterate fori < m
. Assuming m is the size of the pattern string we won't fully fill out the table, should the preprocessing iterate for i <= m ? Or is m here the size of the pattern+1? Or maybe I am misunderstanding something. Any clarification is appreciated!Thanks, Anup