Knuth–Morris–Pratt(KMP) Pattern Matching(Substring search) Part2

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

I think this is one of the most required explanations for KMP. It is missing almost everywhere else and the algorithm is being blindly followed incase a mismatch occurs. Thanks a LOT.

Aditya-mksm
Автор

Even Abdul Bari didn't explain it in so much detail. Best explanation on the planet!!!! Thank you so much I thought I'll never understand this algorithm but you've made it so easy. Thanks again!

nehaliacharya
Автор

He's best. I have seen several other videos but none of them has explained why we have to look at previous index and then find out the longest suffix which is also prefix.

Reason is :
Let's say we have come across a mismatch at some "j" & "i", j < i :
1. character at index "j" is not matching with character at index "i".
2. We know that the prefix (0, j-1) matches with (i-j, i-1).
3. Now we have to look at what is the longest suffix which is also prefix for the substring (0, j-1). And this will also be the longest suffix for string ending at index "i-1". This is the trick.

Thank you Tushar!! You nailed it!! More power to you!!

rakeshvarma
Автор

I've spent more than a week reading articles and watching tutorials to figure out how the hell these values came from but here it is explained in just 9 minutes. Clearest explanation seen so far!!

CyberrGG
Автор

Tried like 15 tutorials before this one ! and my search ends :) superb keep it up

saranshsawhney
Автор

Way better than other complicated explanations.
Please make a series on tough interview questions asked in Google, Amazon etc.

nikhilnvj
Автор

the interesting thing to notice is that the logic is very similar for when we are creating the preprocessed array and when we are matching the pattern.

malharjajoo
Автор

I rarely comment.
"This is by far the best explaination on KMP algorithm I found on Youtube. And I've watched lots of other videos."

Elektroingenieu
Автор

Finally with this video i understood the whole logic behind building LPS[ ] array. Very Clear and Concise explanation.
Thanks.

ahsan_kamal
Автор

Thanks for both those videos. YT recommended me this video. I came in only hearing about KMP and 20 minutes later came out with a good grasp of the algorithm. Great work :)

mattcay
Автор

Thanks! This was a great video. Computing the failure function is the trickiest part of the KMP algorithm!

AlonsoGutierrezCh
Автор

A great example is always better than a lot of talking information. Thank you!

julioabcdefghijulio
Автор

i was totally upset in the part 1 now i am fully cleared....thank you tushar....

fazithfouseen
Автор

Pretty much useful for everything, Competitive Programming and Interviews. :)
Keep the work going on.

KrishnaKishore
Автор

Thank Tushar sir. You are doing amazing job for us. I go through the many tutorials but didn't understand KMP. Now its completely clear. Thanks a lot.

SamrathNagar
Автор

so lucky to find you...simple and clear way Tushar Sir.

ananyadixit
Автор

Finally someone talks about what the number stands for...thank you!

chenyangwang
Автор

Finding the value of pi for last index clears all d
themks a lawt!!!

adityaparasar
Автор

Man, you gotta realize that how much you help me, thanks you very much, you're my god!!

陳翰儒-dm
Автор

Way better than any other explanation article or tutorial on the internet (definitely true for a rookie like me).

raghurrai