Legend! I couldn't figure it out after an hour of looking at my lectures but within 3 minutes of you explaining it just clicked! Thank you!
@shubhampathak10809 жыл бұрын
I have got my exam tomorrow and this video really helped me to understand the edit distance algorithm thoroughly. Probably one of the best explanation that one can find on KZbin for edit distance. Thank you very much !
@vaibhavmourya65 Жыл бұрын
mine is tmrw.. 8 years same vibe
@nihadbkirli347Ай бұрын
@@vaibhavmourya65 2024 same vibe tomorrow exam
@vaibhavmourya65Ай бұрын
@@nihadbkirli347 I am graduate now 2024 batch
@sbahuddin11 ай бұрын
I spent hours and couldn't figure it out. You explained the concept so nicely in just 9 minutes.
@namazbaiishmakhametov64244 жыл бұрын
Crap, man, in a little over three months it will be 6 years since you shot this video, and it helped me today! Thanks a lot, Tushar, and I hope you're doing well these corona-days!
@melogens9949 ай бұрын
I have been spamming your videos before the olympiad in informatics and they are quite literally my lifeline. Thanks so much for these videos!
@novicaovuka54806 жыл бұрын
Man, you helped me a lot. I have an exam soon. And I have to learn a lot of code which I don't understand. After watching your video, man, that code is so easy. Thanks a lot.
@amanbhandari3494 жыл бұрын
You learn code!!??? Wtf
@tuncdogukan7 жыл бұрын
I got the idea of the algorithm quickly. It's a nice and clear implementation with good explanation. Thanks for the effort to pass on the knowledge.
@aashkas Жыл бұрын
Thank you, I had been looking at some dp question for days. Your explanation and graph really became a breakthrough.
@evergreen77814 жыл бұрын
I can say that, you have the best Dynamic Programming KZbin tutorial in the market ❤️❤️❤️
@ksankitha8 жыл бұрын
Tushar your explanations are extremely clear and have been immensely helpful Great job .Looking forward to more videos from you .Please keep them coming !
@pvpk19948 жыл бұрын
Man! Respect! Awesome Job! ..i spent hours together breaking my head on this before seeing this video! Lucid Explanation!
@ertagon2 жыл бұрын
Simple and straightforward. I looked at 3 different videos before this. This is a really good explanation.
@DominicClaxton8 жыл бұрын
I didn't understand this until I watched your video. Thanks a lot!
@FF-ne2qz8 жыл бұрын
You didn't say why this works. It is very important!
@bioinfo93868 жыл бұрын
He actually did, even in detail- you´d better watch the clip again..
@azklinok8 жыл бұрын
He did not. He told us the method, not its proof.
@wanghaochen35158 жыл бұрын
What kind of proof do you need? If they are the same, then do nothing, if not, add 1 more operation to whatever gets the least in previous ops. To me, the logic is pretty obvious.
@azklinok8 жыл бұрын
The logic is obvious to all of us. I want to know WHY the logic works, and gets us the right answer.
@wanghaochen35158 жыл бұрын
azklinok Well. First of all, if two characters are same, you don't do anything, that's clear right? If not, then there's 3 possible moves: delete, replace and insert. Suppose your rows represents str1, cols represents str2. If you wanna delete, you go back to previous column, which is T[i][j-1], because you'd like to retrieve the last character in str2. Similarly, if you wanna insert, you go back to previous row, which is T[i-1][j]. For replacing current character, you need to retrieve last character in both str1 and str2, which is T[i-1][j-1]. At last, you get the minimum among the above 3 moves and plus 1 to it to get T[i][j]. I'm not sure if I articulate it in a proper way, at least that's how I understand this problem.
@xlOogh0stoOlx9 жыл бұрын
Thank you so much. I have computer algorithm exam tomorrow and this video really helps me. You're the man.
@Daniel-to5jd4 жыл бұрын
the best video i have found on this topic so far, you explain it better than in a paid coursera course
@tristangrobler49508 ай бұрын
This is really cool! 9 years since posting and it helped. Nice work!
@4ythere9 жыл бұрын
Hey, I feel you should also hover over optimal subproblems and what a state of the DP represents, For example, In this question, when not equal, you take the min of(top,left,diagonal) , where in you should explain that the top refers to inserting a[i], left refers to deleting a[i] and diagonal refers to editing a[i]. On a side note, you should have mentioned the case where the cost of edit, insert and delete are different.
@sankethb.k6425 жыл бұрын
Thank you
@manoharyedla3604 жыл бұрын
@@sankethb.k642 worst lecture
@abhishekk.39774 жыл бұрын
7:00 - Diagonal ( EDIT) 7:25 - Left ( DELETE ) Top -> Insert (Implied)
@beanlighter94914 жыл бұрын
yes but this is how indians study can you guys recommend me a more detailed lectures?
@Cube2deth4 жыл бұрын
@@parmoksha +1 I don't know why they complain! His videos are not meant for proof or theory or how he thought of the solution just how to solve a problem, which is what we are all trying to learn
@ayanpaul274 жыл бұрын
Short and crisp explanation.. Thank u so much... Finally i got to understand this
@amith89rm4 жыл бұрын
I salute this guy!!! Thanks so much for the video. I was cracking my head to solve this problem. your explanation helped me understand in less than 10 minutes
@sagnikrana70164 жыл бұрын
Hey Amith, I understood the approach. Could you help me explain why this method works?
@kushal14 жыл бұрын
Thank God, you did before I am learning DP. Intuition building is hard and there is a way. My instructors don't know it. You know it and you show it.
@cppprogramming7 жыл бұрын
Tushar, your explanation of how to populate the table, and then how to work it backwards to identify operations was awesome. Thank you.
@janedawg0911 ай бұрын
your clear explanation as to how each number came up for each cell is really helpful (also the shortcut). i've been having a hard time understanding the this but you removed the complexity with your explanation
@prashantjindal86978 жыл бұрын
Your videos on dynamic programming are extremely helpful....!!! Great Job Tushar.....!!!!
@studyaccount7942 жыл бұрын
Bro really drew the 2d array even before starting the video.
@digusbickus3 жыл бұрын
I've been slamming my head against this problem for days. Cheers! You made it very understandable and easy to grasp.
@mr.mystiks99685 жыл бұрын
Awesome video. I already knew how to write out the DP table and but deriving the edit operations being done from the table was the crucial part I did not understand. This was a big help.
@abhijeetkumar22044 жыл бұрын
Evergreen video even u can watch this video 10 year later and understand the dp.
@mesosiderite46702 жыл бұрын
you're better than my teacher greetings from Quebec
@studywithrobin27153 жыл бұрын
You explain it a lot better than some of the newer videos.
@daydreameravani8 жыл бұрын
Without you video, I will definitely fuck up on leetcode. Thx a lot! Please keep doing this!
@yusniamaliah45228 жыл бұрын
i have been looking for tree edit distance theory, and this is the best explanation ever. i just watch at once, i really understand. thanks for sharing education. I'm subscribing U right now..
@karthikeyanm.v83816 жыл бұрын
thing is that you teach better than my professor . thank you bro
@monapanah9 ай бұрын
Bravo! one of the best teachers in this field! thank you
@DignsagYT7 жыл бұрын
Until this video I could not wrap my head around it. So thank you very much. Straight to the point.
@CodeFromSoul3 жыл бұрын
How the hell people think so out of the box to solve problem, I can never imagine this problem can be solved this way... really burst up 🤯
@abhijithtk9 жыл бұрын
I think this is one of the best explanations out there for this problem. Thanks much. Your implementation is very simple too. love it.
@YanuarTriAdityaNugraha9 жыл бұрын
+Abhi Tk Absolutely, very easy to understand. Keep going.
@simiyutube3 жыл бұрын
old video Tushar Roy but really helpful. I appreciate your help. Made this pretty straight forward.
@yinkaige51692 жыл бұрын
Great explanation! So so much easier this way to understand this way
@AntiochsAdvocate3 жыл бұрын
Got stuck on this problem in an NLP textbook and this really helped tysm :)
@sharpdemon9 жыл бұрын
Wow very nice man! I will definitely go through all your videos to brush up my algorithms!
@ankursuri38536 жыл бұрын
This is the best explanation I have found sofar. Thanks so much Tushar! Keep up the good work.
@uditkanotra93934 жыл бұрын
please understand where the formula came from Use f[i][j] to represent the shortest edit distance between word1[0,i) and word2[0, j). Then compare the last character of word1[0,i) and word2[0,j), which are c and d respectively (c == word1[i-1], d == word2[j-1]): if c == d, then : f[i][j] = f[i-1][j-1] Otherwise we can use three operations to convert word1 to word2: (a) if we replaced c with d: f[i][j] = f[i-1][j-1] + 1; (b) if we added d after c: f[i][j] = f[i][j-1] + 1; (c) if we deleted c: f[i][j] = f[i-1][j] + 1; Note that f[i][j] only depends on f[i-1][j-1], f[i-1][j] and f[i][j-1], therefore we can reduce the space to O(n) by using only the (i-1)th array and previous updated element(f[i][j-1]).
@alessiodenny61234 жыл бұрын
excellent thanks ! More useful than 3 hours of lectures at school
@afiyatiamaluddin90344 жыл бұрын
Thank you very much, this is my AHA MOMENT. This is what I'm looking for all this time.
@achilles1659 жыл бұрын
Great series of videos to prepare of interviews... already subscribed to your channel... One suggestion though... instead of directly jumping to the matrix right from start... it would be awesome if you could explain the solution for a min or 30 seconds, in terms of what you will be doing before jumping to solving of the table. Although you kind of mention the formula in the end, but it would be better if it is verbally explained at the beginning and then mathematically written at the end. That would help people in understanding that how DP can solve this problem in the first place.
@bernardoalvarenga26076 жыл бұрын
Excellent explanation, great clarity. I've seen a video from CS50 on the subject that was a mess. This is great.
@willgoydych4403 Жыл бұрын
This guy really casuallly out here just helping peopel
@sigmoid35964 жыл бұрын
respect !! i pass the exam because of you
@ce097priyaraina2 Жыл бұрын
best explanation i have seen so far..
@1piecegaming6223 жыл бұрын
thanx thanx thanx bro....Dynamic programming is sick to understand but this logic helps me a lot....Thnaks bhaai
@perfectfalse12 жыл бұрын
THIS WAS A HUGE HELP. Thank you for posting this.
@gururajraykar92543 жыл бұрын
Just awesome video. Was searching short video which i can learn this algorithm.
@PAIETES199 жыл бұрын
Best explanation on the internet! Thanks for the video
@the_sweet_heaven4 жыл бұрын
Nice problem, Nice solution, and of course excellent explanation. +1 tushar
@eshwareducationsolutions20919 жыл бұрын
this is the best explanations. Thanks much. Your implementation is very simple too. I really helped for my exam.
@cadmonyuen61419 жыл бұрын
You are doing a really good job. Keep up man.
@Harow77 Жыл бұрын
Thanks sir, cleared all my doubts in a short time.
@vvsatyanarayanareddyn46419 жыл бұрын
DP was my nightmare , always used give up , after watching your videos, its like DP marathon at weekend. thanks a lot
@noone-ip8qs4 ай бұрын
How is it going on now
@akshaytata9 жыл бұрын
Holy Shit, Who is the guy who made this algorithm! Awesome explanation!
@ghakol3 жыл бұрын
thank you so much for this video!! i have a test on this in a few hours and this explanation was really helpful :)
@sheikhs14757 жыл бұрын
Love from Pakistan. So simple. So concise. So comprehensive.
@taoyan80078 жыл бұрын
I completed this question on leetcode online judge, after watching this video I had a deeper understanding of Dynamic programming
@MegaMiley6 жыл бұрын
Thank you!! This is the second time already a video of you made a problem 'click' for me :D, it all makes so much sense now!
@KameshwaranTheInsane7 жыл бұрын
I owe you so much Perfectly presented. You had explained this within 10 minutes Thank you very much...
@muthurajramalingakumar23614 жыл бұрын
Thanks for the upload! The intuition behind taking the Min of three cells would be helpful.
@Anne-ug4jv6 жыл бұрын
I have NLP exams tomorrow. Thank you very much for this!
@ts-gaming-295319 жыл бұрын
Very good short video . Good job.
@agrimasrivastava20609 жыл бұрын
Thanks a lot Tushar. One of the best explanations I came across. :)
@milesstephenson48736 жыл бұрын
Thanks, Tushar. Very clear explanation.
@PremshainyKumarChintapal-vw3ip2 ай бұрын
sir i want to say one word just wonderful
@rialaurent-hughes71918 жыл бұрын
Thank you, that was perfect. Explained better than my lecturer
@ahmedboutaraa87714 жыл бұрын
shout out to you man. really empowering content.
@dhanashreepawar93297 жыл бұрын
Good and clear explanation. Easy to understand!!!
@manasbudam71929 жыл бұрын
absolutely better explanation than wikipedia!!!........thank you man!
@bhargavtenali8 жыл бұрын
Your videos deserve a great applause :)
@a50x6 жыл бұрын
Great explanation, easy to understand, really helped me to clearly understand DP
@logicraju8 жыл бұрын
Awesome video, bro ! Was very useful !
@sagarrathore82423 жыл бұрын
such a great explanation sir😁
@josegermanparra60644 жыл бұрын
Thanks for a clear and concise explanation!
@yuhua19948 жыл бұрын
Helpful video! Totally understand after watching your videos :)
@maielshazly60548 жыл бұрын
Your explanation is really clear. Thank you very much
@latheefjunior8 жыл бұрын
Bro, you've done a wonderful job here. Thanks!!!
@dimitrisdimitriou69698 жыл бұрын
Tushar! Awesome! Great job!
@alvaro11216 жыл бұрын
Thank you my friend! Very clear explanation of the algorithm
@rdforte3 жыл бұрын
This was very informative and helpful. Thankyou!
@sahnawaz8 жыл бұрын
one thing he did not mention how we detect addition. so when computing all kind operations, if you move up the cell (e.g from (2,1) to (1,1) that means we need to add that particular row character in the conversion.
@umerwaqas59438 жыл бұрын
wonderfull way to teach. it was so difficult for before watching this. thanks
@jarias148 жыл бұрын
Thank YOU for explaining this in detail.
@vyshnavramesh93054 жыл бұрын
In MIT DP 3 video, Eric explains the logic behind the "min(the three cells)" beautifully. In short its the representation of insert, delete, replace.
@srinivasdesai38016 жыл бұрын
I have few suggestions, 1. As many people have pointed out, I don't think I'm getting to know why this solution works before seeing the complete video. It would be helpful if Tushar goes over other approaches as well to prove that this solution works or mathematical proof shall be sufficient. 2. I think it would be better if the video explains what happens to the string(s) when we delete a character(s) and how the comparison shall be made rather than asking to the take the minimum of top, left and diagonal 3. Adding to the second point, if the characters are not same, I don't think it is just 1 + Min(cost(top), cost(dia), cost(left)). I think it shall be min(1 + cost(top), 1 + cost(left), 2 + cost(dia)). Because, when we are taking from the diagonal we are removing one element from str1 and one from str2. Assuming cost of removal is 1, it shall be 2 + cost(diag) rather than 1 + cost(dia) I welcome any suggestions for correction.
@ericchen12486 жыл бұрын
Nope, it's talking about changing one string into the other, so you're either operating on str1 or str2. If you want to go down that route, then by the way string is stored by computer memory, insertion or deletion should cost much more than changing. This is just the definition of edit distance. Of course, if you want to go to variants where there are different costs, your point is correct. As for the explaining part many people are asking about, he has a lot of videos on dynamic programming itself, it's basically all the same logic, and would be rather redundant for viewers otherwise. You can check out other videos explaining DP to get a better understanding, but here is a cut short version Dynamic Programming works because when looking for answers for a question with length of n, we can look at it as an answer for question of length n - 1 ( or some other lesser length, generally something that can be achieved from an atomic operation ), plus some trivial atomic operations. So in the case of edit distance, what is an atomic operation on string edits. We have insertion, removal, or changing. And if you create a table like the one in the video, the three separate n-1 length question corresponds to the three cells to the left, diagonal, and top. The minimum of the three is choosing the best way to starting point from the previous three states, and + 1 is the cost to go from that state to the current state.
@uditkanotra93934 жыл бұрын
Use f[i][j] to represent the shortest edit distance between word1[0,i) and word2[0, j). Then compare the last character of word1[0,i) and word2[0,j), which are c and d respectively (c == word1[i-1], d == word2[j-1]): if c == d, then : f[i][j] = f[i-1][j-1] Otherwise we can use three operations to convert word1 to word2: (a) if we replaced c with d: f[i][j] = f[i-1][j-1] + 1; (b) if we added d after c: f[i][j] = f[i][j-1] + 1; (c) if we deleted c: f[i][j] = f[i-1][j] + 1; Note that f[i][j] only depends on f[i-1][j-1], f[i-1][j] and f[i][j-1], therefore we can reduce the space to O(n) by using only the (i-1)th array and previous updated element(f[i][j-1]).
@tejasnaik16713 жыл бұрын
Great logic bro!!! Really made the problem ez
@sritharan209 жыл бұрын
Hi Tushar, Great Job Man, one small suggestion-> it would be great maybe if you tell about the practical application of the programs we can actually do some real time implementation of it and i think it add more value to it :). Kudos Happy coding!!!
@sarikaranjitkumar1744 жыл бұрын
Thank you for the great explanation!
@sahithikambhampati45714 жыл бұрын
Super explanation , This is so much usefull for me
@malvikark1244 жыл бұрын
Great explanation. Thanks so much!
@masoomakram42709 жыл бұрын
Awesome explanation... Finally I understood. Thank You.
@maralsalamzadeh10523 жыл бұрын
Perfect description 👌
@younusahmed237 жыл бұрын
hey thank you for this video it was extremely helpful and it helped me understand a complex concept in only 10 minutes. Awesome video
@apoorvchaturvedi66149 жыл бұрын
very nice explanation...thank you Tushar.
@Toxx989 жыл бұрын
Thank you for your videos, helped me understand it properly.