I have a question about KMP’s failure function f. Assume that the size of the pattern is 2^q where q is bigger or equal to 8.
How can I find values of f(m/2) and f(3m/4) if I know f(m/4) = 0 and f(m) = 3m/4 in advance?
What kind of strategy I should follow? I think I get the KMP algorithm more or less but I can not find out a way to think here. Any hints are appreciated.
We know that f(m)=3m/4. So, it is necessary that f(i), with i belonging to {m/4;m}, must be equal to i-m/4 (all natural numbers between 0 and 3m/4).
So in this case, f(m/2)=m/4 (because m/4=m/2-m/4) and f(3m/4)=m/2 (because m/2=3m/4-m/4)