Visualization of Knuth-Morris-Pratt Algorithm

preview_player
Показать описание
Visualization of Knuth-Morris-Pratt String Search Algorithm

Рекомендации по теме
Комментарии
Автор

You know, most of the people who try to explain the algorithm do such an extensive explanation, which can leave the student really confused. Visualization of the algorithms is crucial and thank you for creating such a video. It's much easier understanding the idea of KMP without actually knowing all the theoretical stuff first.
I am not talking about running it, but actually getting the idea on why this works

ice_the_kicker
Автор

I found this demonstration extremely useful — thank you!

matanshtepel
Автор

Your step-by-step ppt is good for learning the KMP algorithm or some string matching! Thank you very much!!!

郝棒哦
Автор

Thank you so much i understood kmp algorithm only because of this visualization vedio

Rajesh-nbde
Автор

Finally Understood!! Perfect Video, Thanks for making this.

CharithaJanapati
Автор

one that still confused me. If j is already positioned 0 then why when T[0 - 1] is 0 instead of -1? or is that a special rule when it reached 0 it cant be decrement again?

TheSkyreborn
Автор

This algorithm seems to only be beneficial if the pattern has repeating characters. Suppose I had "abcdefg". Wouldn't my lps table contain all zeros?

AK-fbzn
Автор

I don't understand one thing. suppose we have a pattern like this:
txt: a a a b a (and so on...)
pat: a a a b b
lps: 0 1 2 0 0

In this case, where there is a mismatch at the last a and b, I understand why pat is started at 0. because there is no prefix that is also a suffix at that point in the pattern.

But why is the txt pointer not shifted back?? How can we be sure that if the pattern is just shifted one place to the right (like in the naive/brute force method) that we won't find a match?

meaning:
a a a b a ...
a a a b b

I know in this case it is not a match, but how can we be sure that this is the case always?

My question basically is, in this algo, we have a i pointer that is iterating through the txt and a j pointer that is iterating through the pat. when there is a mismatch, the j pattern is shifted back a certain amount (which i understand why) but the i pointer is not shifted at all. THIS is what I don't understand. j pointer is shifted based on if there is a prefix that is also a suffix and that makes sense. But i dont understand why the i pointer is not shifted REGARDLESS of whether a prefix is found or not.

anonymoussloth
Автор

the kmp failure function values are completely wrong

yesimtaco
Автор

interesting algo. seems like it can be improved tho

Christian-mndh
Автор

is this supposed to be the 28. problem leetcode solution?
wow

LeonardoCruz-yfqx
Автор

Brown Angela Jackson Helen Miller Susan

SymonsChasel-fw