-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Error in "Compressing a string" section in "Prefix function. Knuth–Morris–Pratt algorithm" #1414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I found out that my claim works only when p!=n (Actually the original paragraph also turns out to have this assumption, but it is not explicitly written), so I propose changing the last paragraph wholly. Now let us assume that $n$ is not divisible by $k$ . We show that this implies that the length of the answer is $n$ . We prove it by contradiction. Assuming there exists an answer, and the compression has length $p$ ( $p$ divides $n$, |
I can't see a contradiction to the initial assumption that |
Ah, now I see that my argument was a little bit wrong. I intended to show a contradiction in another way but I got mixed up. Now I change the comment a little. Now let us assume that $n$ is not divisible by $k$ . We show that this implies that the length of the answer is $n$ . We prove it by contradiction. Assuming there exists an answer, and the compression has length $p$ ( $p$ divides $n$, |
Ah I see, would you need to add the definition/condition that |
Yes, you are right in pointing that out. |
Uh oh!
There was an error while loading. Please reload this page.
I think "But then the string consists of only one character repeated over and over, hence we can compress it to a string of size $1$ ..." is false. Shouldn't it be written: "But then the string consists of$gcd(p, k)$ characters repeated over and over, hence we can compress it to a string of size $gcd(p, k)$ , and since it divides $p$ it also divides $n$ ."
Example: k = 4, n = 12, p = 6.
The text was updated successfully, but these errors were encountered: