thank u , this is the best kmp-algorithm introduction i have never seen, i love your video. now is 2023, but your video is classic and simple for everyone who want to learn kmp truly!
@shubhamgoyal75969 жыл бұрын
How someone can give such a easy explanation of such a harsh topic...you are awesome sir.
@tusharroy25257 жыл бұрын
thx.
@aksharmishra9693 Жыл бұрын
Damm 8y old comment😮 Bhai abhi aap kya krte ho
@Your_Soul_13Ай бұрын
@@tusharroy2525 sir aap bhi jaat hai kya
@aliaksandrsheliutsin23743 жыл бұрын
I spent 2 hours reading algo book and papers but understand nothing. I watched your video 2 times and understand everything. Thank you very much!
@d2macster8 жыл бұрын
this visualization in 5 minutes explained what took me 2 hours reading other sources
@manasbudam71928 жыл бұрын
I think this is the best introduction any one can get for kmp.It will be better understood if you stress the lps array as an automaton which shows the index from which the comparision must continue.Thank you Tushar sir. Once again I want to say that this is the best introduction any one can get for kmp.
@111rhishishranjan2 Жыл бұрын
After 7 yrs, what you do now sir??
@howhello3549 ай бұрын
@111rhishishranjan2 after 7 months, what you do now?
@shubh137992 жыл бұрын
old is gold, now this person is working as a technology lead.
@BackToBackSWE6 жыл бұрын
This video is great, really clarifies things.
@dampdigits5 ай бұрын
Beautiful explanation. You address the actual logic of finding the longest suffix that is a prefix in a substring, which it easier to understand.
@RudolfEremyan9 жыл бұрын
The Best explanation of KMP in KZbin)) 12 minutes of helpfull information)))
@sharcodes Жыл бұрын
Watching this video on 2023, I can say you are the real gems. You made a video when no was making such good quality content. Thank you 😊.
@SanaMalik-ss3sh8 жыл бұрын
very good work. I have seen a lot of videos about this topic but this is best one through which i have completely unterstand this topic........Thank you sir
@AbhishekSharma207 жыл бұрын
I browsed over internet for hours, and still couldn't get such a simple explanation as this. Then I remembered this song: "Jag ghumeya, thare jaisa na koi". Thanks for uploading. You're helping thousands of people.
@RamendraSinha6 жыл бұрын
দ্য ঃ ডট t do এত দূর
@bhavukmathur27098 жыл бұрын
Can the fees that I innocently paid to my college lecturers be taken back and given to you..??
@santuchaitu8 жыл бұрын
very True. Thank you Tushar for explaining very clearly.
@vis40sinha7 жыл бұрын
mathur ji emotional(bhavuk) kar diye
@johnzhang43537 жыл бұрын
i totally agree with you.
@shubhamgarg42277 жыл бұрын
zyada bhavuk ho liye :P
@tusharroy25257 жыл бұрын
I can take the money...:)
@hillstudios13 жыл бұрын
One of the best.Tushur is like a saviour who comes helps humanity and never returns back
@anuveshkothari9 жыл бұрын
this video made KMP pattern matching very simple ... all thanks to tushar
@almamun. Жыл бұрын
Number one explanation all of kmp tutorials in utube.
@ravi-mo6js6 жыл бұрын
Very good and simple explanation bro.. Ofcourse we INDIANS are legends in these cases..
@webv27558 ай бұрын
Best video so far I watched for KMP Algorithm, Watching in 2024...
@plontulublalulu Жыл бұрын
You are consistently the best explainer of these concepts. Thank you a ton
@aj97064 жыл бұрын
Explanation for Prefix array building in this video is the best in KZbin.
@harpercfc_2 жыл бұрын
I promise you this is the BEST KMP algorithm tutorial around the world. Thanks for your video which made me understand KMP finally. Really really awesome!
@jatinbalani1349 Жыл бұрын
Very precise explanation. Examples are used and explained simply.
@robertpierce51429 жыл бұрын
The best explanation of the failure table I've found so far. Thanks!
@adeypurohit01 Жыл бұрын
The only place on YT where I understood KMP !! Thanks a lottt Sir 🙏
@monx4 жыл бұрын
The first 5 minutes explaining the intuition is time well spent. Thanks Mr. Roy!
@Alpha-nn8mn Жыл бұрын
7 years old video, but still one of the best! Thank You Tushar
@balajijayasankar45028 жыл бұрын
A very simple and clear explanation to a seemingly complicated algorithm. Glad I found this.
@saurabhprasad44994 жыл бұрын
You are a naturally good teacher Tushar
@mubeenullhaq64298 жыл бұрын
Just watched this video 5 hours before the exams .. found it so much easy.. God bless you Sir. Respect from Pakistan...:)
@shuyao52486 ай бұрын
I couldn't understand this earlier. now I'm very clear about this. Such a awesome explanation. Thankyou very much sir.
@ajinkya50439 жыл бұрын
This was really really helpful...no other video explained KMP algorithm upto this level of clarity...Thanks Tushar Sir!
@tusharroy25257 жыл бұрын
welcome
@111rhishishranjan2 Жыл бұрын
what you do now ??
@mayurbhat65647 жыл бұрын
Awesome sir I have never ever understood this kmp in my class as best as u taught.... Congo
@aditijain5159 жыл бұрын
Wow....This is the best explaination one can ever get on KMP. Thanks alot :)
@tusharroy25257 жыл бұрын
welcome
@tusharchamp4883 жыл бұрын
@@kamalkishor543210 kuch jyada hi hogya ye toh
@nataliazolotukhina94699 жыл бұрын
I've watched lots of videos about KMP but this explanation is the most useful! Thank you!
@ghostgutarist52345 жыл бұрын
Me: I will learn KMP. He: Prefix, Suffix, Suffix, Prefix.... Me: Damn, I am confused... maybe Some other day.
@sunguru9815 жыл бұрын
LMAO .. Same here XD
@akashjain73785 жыл бұрын
Check out Abdul Bari's video on the same topic. You will surely understand!
@gabrieledarrigo3105 жыл бұрын
lol
@sarkarsh55375 жыл бұрын
@@akashjain7378 More like check Abdul Bari's video, and come back and watch this video, because I think both videos are helpful to get a clear understanding of the entire concept.
@hagartm4 жыл бұрын
Some algos you can tackle in one attempt, the others(?) .... you have to grapple with a bit more. :)
@MatyyRdk6 жыл бұрын
Hands down best videos on algorithms
@lolno65277 жыл бұрын
Tushar you are doing a superb job buddy! I have stopped going to my lectures. I got a 46/50 watching your videos on my midterm! Thanks mate! With love from Canada!
@111rhishishranjan2 Жыл бұрын
what you do now ??
@AbhayKumar-oz4oh7 жыл бұрын
you are awesome,after watching this vdo KMP algo is very very very very simple for me Hats off to your teaching style sir
@malharjajoo73938 жыл бұрын
Basically to understand what happens at 9:40 - Useful to understand - Value stored in the array at index "i" - Length of prefix matched ( from the start , hence we do A[i] = j+1 ) upto that index i. "j" index - this is actually the length of the prefix matched from the start. This index keeps on getting reset ( not always to 0 ) . "i" index - this is just iterating through every character of the substring. 1) We increment "i" whenevr there is a mismatch ( A[j] != A[i] ) and j=0 or if there is a match ( A[j]==A[i] ,in which case j++ is also done ) 2) We "reset" "j" whenever there is a mismatch ( A[i] != A[j] ) But how do we reset it ? Key logic - Go to index j-1. look at A[j -1 ] , this gives prefix length matched upto current "i-1". Hence we start checking from A[A[j-1]] against current character at "i". To convince yourself of this , think of "j" and "i" moving together when they match characters.
@youarecorrectiamwrongbecau13383 жыл бұрын
this should be the first/pinned comment
@ChalanthornC3 жыл бұрын
THX!
@braceyourself10972 жыл бұрын
bruh
@chloeyeocodes4 ай бұрын
Thank you!!! The explanation at 3:24 was so good! It really helps if you watch this video with the pseudocode for the prefix/lps table and the peusodocde for kmp search in front of you 😄 happy coding!
@azgddis5 жыл бұрын
Search logic first Kmp to understand the complete logic. Excellent explanation with code.
@AnkitSharma139 жыл бұрын
Superb explanation. Wow. Had been to so many other channels to understand but in vain. Thanks Tushar.
@FrostyBaka7 жыл бұрын
Best explanation of KMP algorithm that i found. Thanks
@snehallotus9 жыл бұрын
Superb explanation of failure function with all the scenarios.. and then the actual string matching algo (y)
@kakyoism4 жыл бұрын
Great presentation. My first reaction to the algo is "Why must we care about prefix/suffix". I found it difficult to figure out the impact with the first example in the video. Then my take: Say if the input Text was "axax...", the Pattern was "axad...", then the initial matching would fail at the second 'x'. However, then we cannot slide "axa" of Pattern past the second 'x' in Text. We must match Pattern's current prefix, i.e., the 1st 'a', against Text's current suffix, i.e., the 2nd 'a'. This is why we must examine the prefix/suffix situation in the substring before EVERY fail point. Another viewpoint of this problem: Without explicitly backtracking the character at the fail point, we don't know if there could be another occurrence of the fail-point character before the fail point, which could from a sub-pattern of interest. Prefix/Suffix heuristics helps us pinpoint/eliminate the possibility of such an occurrence.
@deathbombs2 жыл бұрын
Sounds really smart
@jdhruwa8 жыл бұрын
Great video.. Simple, sufficient and conceptual.. I can`t find any better resource than this to learn KMP algo Thanx a lot
@thomasnn9 жыл бұрын
Great video, my book had me all confused about how to fill in the table :)
@zheyuanxu19386 жыл бұрын
it's fairly straightforward
@blasttrash3 жыл бұрын
I know its 5 years late but do you remember what book?
@chaoticmind-z2 ай бұрын
THANK YOU!!! I struggled to understand why you go to the value of where (j - 1) is when a mismatch occurs when setting up the Pi table. You are applying the same comparison logic here when setting up the table that's used when comparing the pattern with another string. The index of where (j - 1) is, is the location of where you should do the next comparison if you get a mismatch. Basically... what you do here is what you do with the KMP algorithm and a string. Finally... I understand thanks to you! God bless.
@mrudul50182 жыл бұрын
Why you left video making. I think you were giving far better explanation in 2015 compared to today's videos on KZbin
@anshaldwivedi91708 жыл бұрын
Sir you are really genius , u make every thing so easy.
@roh99346 жыл бұрын
I cant thank you enough for your help and contribution in my life learning DS and Algo. You are the Man.
@aishy7 жыл бұрын
Watched a lecture by Sedgwick on the topic twice, and banged my head with the Deterministic Finite state Automata.. But, you just have a knack of simplifying complex shit.. Hats off !! Coding really made simple..
@arunvyas278 жыл бұрын
Thank you Tushar, I have always tried to escape this algorithm due to its complexity. But with your video i was able to get it in 12:49 mins :) :) Thanks a lot.
@saranghae37203 жыл бұрын
@@sasmitvaidya exactly 😂
@caesarz77046 жыл бұрын
At first I do not understand what you are talking about, then I went to read blogs and books about KMP, I got even more confused. Then I go back here to watch this video again, finally found your method is the simplest way to achieve KMP. Nice job mate!
@celxiusgaming7 жыл бұрын
Just had to say that this made understanding a complex algorithm, very simple. Thank you so much for posting this and all the other videos you do!
@ppcuser1007 жыл бұрын
Very visualized clear and quick message. Great! In other teacher's lessons formalism sentences kills the idea.
@sushants27197 жыл бұрын
Awesome explanation. I didn't come across any other material that explains KMP as simply as this one. Good work, man.. Keep it up .. :)
@akshaygupta86189 жыл бұрын
awesome sir .. u just made it easier for the students of ipu to clear the exam of ADA😀😀😀😀😀😀😀
@sriramv43068 жыл бұрын
Excellent! Would be interesting to know the logic behind this algorithm, like how it was formulated.
@muditkhanna8164 Жыл бұрын
This video made me clear, let me make it more clearer for anyone in comments whenever you find a match of suffix and prefix (pre-requisite concept) ,now you are matching the string the from the next index's of the previous matched prefix-suffix matched element and the text string does not get backtracked that's how it saves time, by not sliding but by jumping.
@siddharthchabukswar25 жыл бұрын
Hello my name is KMP and today I'm going to talk about Tushar.
@ashishshetty35123 жыл бұрын
Lier
@vikrant46666 жыл бұрын
this man is working in apple now , he is great achiever , we should learn from this dude
@saikumarganganapalli59576 жыл бұрын
At 7:29 Why are we filling the lps in that fashion.? Why should look at prev character's stored value? Nice Video Although
@jap9638527412 жыл бұрын
Awesome, His video is always the easiest to get the core knowledge about the algorithm.
@gotoexplore68744 жыл бұрын
interesting the sufix-prefix sub algorithm.
@leemarchelloopperman3729 жыл бұрын
Great work Tushar, my textbook confused me but this video has given me a better grasp of the kmp algorithm. Thanks alot
@USIndian518 жыл бұрын
While buliding the array at time 5:59, when character at j=0 and i=1 didn't match,you incremented the value of i but at time 7:3o when character 'd' at poistion j=3 didn't match the character 'a' at position, you didn't increment i but looked into the lookup table of the previous chatacter to get the postion of j. So, the question is when there is a mis match when do increment i and when do you peek into the lookup table of the previou character to get position of ? Do we have to handle special cases at the beginning and also the last character in the pattern? You explanation was excellent except for this one doubt.
@indianfootball23285 жыл бұрын
Increment only when there is a match or j=0, If there is mismatch lookup at value j-1 and match again
@giorgi233 жыл бұрын
Idea is that when sequential characters don't match you go back and check for the longest prefix that is the same as the suffix you are standing at. If there is no prefix available then you need to go forward and start comparing characters at the beginning of pattern with the string
@sheikhomur4897 Жыл бұрын
Thank you very much sir, This is the easiest way to understand the KMP and described it amazedly.
@souvikdatta977 жыл бұрын
Thanks a lot sir for explaining this so clearly and nicely!
@jvst77282 жыл бұрын
can i say why this video is better than other it is because he has taken a very good example, which was clearing many doubts
@srishti16134 жыл бұрын
Who else thinks that this person looks like Gautam Gambhir. Like here 👇👇
@Sushil28744 жыл бұрын
Exactly..!!
@mrudul50182 жыл бұрын
I was banging my head here and there for KMP and finally got this video.
@SUPERRICHKIDS4 жыл бұрын
I can skip this class because of you
@TY-hr5bn3 жыл бұрын
Thanks! Great explanation! "The point is where we start in the pattern for the next comparison"
@compscilaw5 жыл бұрын
The time complexity to build the next table is O(m) not O(n).
@witslost5 жыл бұрын
it is Big O (Big O)) actually
@compscilaw5 жыл бұрын
@@witslost You're big square.
@witslost5 жыл бұрын
@@compscilaw no i am Big O(square)
@compscilaw5 жыл бұрын
@@witslost On the internet, no one is supposed to know you're a dog; but your profile picture gives it away. No one is supposed to know that I'm nine squirrels in a human suit.
@witslost5 жыл бұрын
@@compscilaw no i am nine Big Os in a human suit
@PRANAVMAPPOLI2 жыл бұрын
Best explanation even after 7 years !
@boheymiyaan9 жыл бұрын
Thank you sir :) This video is really helpful. Thanks a lot :)
@sayakpaul31529 жыл бұрын
+Sumit Biswas Totally agreed. Nothing could be better.
@boheymiyaan9 жыл бұрын
:)
@0spidey15 жыл бұрын
Thanks a lot man. I was studying from the notes another student took, didn't understand a thing. Downloaded the lecturer's slides, didn't understand a thing. I watched your video for 5 minutes and it all made sense.
@adigenius044 жыл бұрын
Anyone studying this in March(or April) 2020 because they have too much free time due to Corona?
@alyson47914 жыл бұрын
I decided to try my hand at making a compiler and this topic came up and my brain is in agony..
@Aliennnaa4 жыл бұрын
hello fellow learner
@arushsaxena95784 жыл бұрын
kzbin.info/www/bejne/qmXbhnRjlq2tr5o refer this Best video ever, Do watch its prefix part
@keshavrathore52284 жыл бұрын
HI bro; pehchana
@sohamgohel1961 Жыл бұрын
I am watching this in oct 2023
@royalbandadancer Жыл бұрын
Best simple approach sir I got this video after 3rd skipped video on KMP
@senthilnathan38349 жыл бұрын
What if there is no common prefix and suffix in the pattern?
@ycjoelin0007 жыл бұрын
No, since you can skip the characters that were already compared, in the text to be searched, it's still O(m) on search, no matter what the pattern is. So it's total O(m+n). (I know this is a thread about a year ago, just leaving comment for other viewers.)
@ujjwalrockriser9 ай бұрын
I saw so many vedios, but this video is god for me. Thank you so much Tushar Sir. Video quality doesn't matter, teaching quality matters.
@user-mo3bk6wv6l6 жыл бұрын
I had to watch this video 5 times in order to fully understand... should I drop out from computer science ?.....
@marcuspolk2406 жыл бұрын
No. According to Sedgewick's Algorithms book, this is the trickest algorithm in his book. Apparently when it was first implemented, one of the maintainers couldn't understand it so he replaced it with the brute force implementation.
@jerwinsamuel6 жыл бұрын
If you were able to understood it in the end, why does it matter. Congrats 👏
@ІванМанчур-е7з5 жыл бұрын
you suck ,I understand it at 4 times.)))
@SoyJayP5 жыл бұрын
No
@kabbu6434 жыл бұрын
Dude he totally confused me
@utkarshpandey5-yeariddelec863 Жыл бұрын
This is indeed the best KMP substring search explanation
@MrAvtar18 жыл бұрын
Best explanation seen so far !! Keep doing this great work.
@ChumpyZhang7 жыл бұрын
There are tons of person explaining this KMP algorithm. So far, the most useful one!
@boyangdong89278 жыл бұрын
Nice tutorial. But i personally don't like the sound when you erase i/j by your finger, that hurts my ear. Please use a eraser/cloth.
@sriniakhilgujulla38927 жыл бұрын
lol
@smbehindyou7 жыл бұрын
hahaha
@TM-qc5oz6 жыл бұрын
You have some serious issues man. Sort them out soon..before you set foot outside ur home..u know people outside make a lot of different sounds..
@teaandy369Ай бұрын
this is best kmp explanation video so far
@jmares938 жыл бұрын
Tushar you are the man
@tusharsaini28013 жыл бұрын
Amazing Explanation , Just Awesome Explanation of how the Algorithm is working . Thank You For such Great Content
@farenew53268 жыл бұрын
thanks a lot, your explanation is easy to understand, but I think if you could add the source code in your video and then explained it would be better. Anyway ,thanks again :)
@anktrj4 жыл бұрын
after more than 5 years of videos being posted! It still feels new! Anyway thanks for the quality content!
@rikhardu8 жыл бұрын
~6:10 small MISTAKE: You say that if two characters are the same, you increase VALUE of the first one by 1 and put it in the value field of the second one... actually you increase index of the character, not the value of the function (which is seen later, when you analyse second 'b': 7:12). Fortunately in case of the first 'a' index and value of the function are the same, so nothing changes in the table... it's just a bit harder to understand due to this small mistake. Nevertheless thx for the videos, they are very helpful!
@Lightyin7 жыл бұрын
He did say value.... but then again he did also point to the index :)
@rodrigomolina20557 жыл бұрын
also in the point 7 the value is zero not 1, in the final step at minute 7:51
@YogeshDorbala6 жыл бұрын
sorry but it is 1
@joseph15866 жыл бұрын
why is 1?
@evanwang55535 жыл бұрын
I think this algorithm is very well explained by Tushar.
@BharatSingh-zk8lx8 жыл бұрын
pattern sounds like parrot
@vincentt.71462 жыл бұрын
U made it so easy to understand, disillusioning me to thinking that even i could have come up with this. Amazing, thank you!
@dhulipalaj2 жыл бұрын
Very well explained. Searching all over found this nice , detailed explanation
@nhutranquynh57665 жыл бұрын
This is the best KMP video i've seen. You explain very clearly that i can understand eventhough English is not my mother tonge. Thank you very much!
@tafsiralam17528 жыл бұрын
Really your videos are so helpful for us sir....your way to teaching is fabulous.
@teamsarmuliadi69607 жыл бұрын
You made it easy as though there is no problem with KMP algorithm.. Thanks