Minimum Edit Distance Dynamic Programming

  Рет қаралды 521,257

Tushar Roy - Coding Made Simple

Tushar Roy - Coding Made Simple

Күн бұрын

Given two strings and operations edit, delete and add, how many minimum operations would it take to convert one string to another string.
github.com/mission-peace/inte...
github.com/mission-peace/inte...

Пікірлер: 503
@mylilcritic
@mylilcritic 8 жыл бұрын
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!
@shubhampathak1080
@shubhampathak1080 8 жыл бұрын
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
@vaibhavmourya65 6 ай бұрын
mine is tmrw.. 8 years same vibe
@pvpk1994
@pvpk1994 7 жыл бұрын
Man! Respect! Awesome Job! ..i spent hours together breaking my head on this before seeing this video! Lucid Explanation!
@ksankitha
@ksankitha 7 жыл бұрын
Tushar your explanations are extremely clear and have been immensely helpful Great job .Looking forward to more videos from you .Please keep them coming !
@tuncdogukan
@tuncdogukan 6 жыл бұрын
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
@aashkas 9 ай бұрын
Thank you, I had been looking at some dp question for days. Your explanation and graph really became a breakthrough.
@FF-ne2qz
@FF-ne2qz 8 жыл бұрын
You didn't say why this works. It is very important!
@bioinfo9386
@bioinfo9386 8 жыл бұрын
He actually did, even in detail- you´d better watch the clip again..
@azklinok
@azklinok 8 жыл бұрын
He did not. He told us the method, not its proof.
@wanghaochen3515
@wanghaochen3515 7 жыл бұрын
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.
@azklinok
@azklinok 7 жыл бұрын
The logic is obvious to all of us. I want to know WHY the logic works, and gets us the right answer.
@wanghaochen3515
@wanghaochen3515 7 жыл бұрын
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.
@digusbickus
@digusbickus 2 жыл бұрын
I've been slamming my head against this problem for days. Cheers! You made it very understandable and easy to grasp.
@somebodymk
@somebodymk 6 жыл бұрын
This helped me out so much! Thank you!
@mr.mystiks9968
@mr.mystiks9968 4 жыл бұрын
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.
@studywithrobin2715
@studywithrobin2715 3 жыл бұрын
You explain it a lot better than some of the newer videos.
@ertagon
@ertagon 2 жыл бұрын
Simple and straightforward. I looked at 3 different videos before this. This is a really good explanation.
@MegaMiley
@MegaMiley 5 жыл бұрын
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!
@sharpdemon
@sharpdemon 9 жыл бұрын
Wow very nice man! I will definitely go through all your videos to brush up my algorithms!
@wreno7879
@wreno7879 7 жыл бұрын
Thank you for uploading this video. It's extremely helpful!
@sbahuddin
@sbahuddin 5 ай бұрын
I spent hours and couldn't figure it out. You explained the concept so nicely in just 9 minutes.
@namazbaiishmakhametov6424
@namazbaiishmakhametov6424 3 жыл бұрын
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!
@DignsagYT
@DignsagYT 7 жыл бұрын
Until this video I could not wrap my head around it. So thank you very much. Straight to the point.
@DominicClaxton
@DominicClaxton 8 жыл бұрын
I didn't understand this until I watched your video. Thanks a lot!
@cppprogramming
@cppprogramming 7 жыл бұрын
Tushar, your explanation of how to populate the table, and then how to work it backwards to identify operations was awesome. Thank you.
@4ythere
@4ythere 8 жыл бұрын
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.k642
@sankethb.k642 5 жыл бұрын
Thank you
@manoharyedla360
@manoharyedla360 4 жыл бұрын
@@sankethb.k642 worst lecture
@abhishekk.3977
@abhishekk.3977 4 жыл бұрын
7:00 - Diagonal ( EDIT) 7:25 - Left ( DELETE ) Top -> Insert (Implied)
@beanlighter9491
@beanlighter9491 3 жыл бұрын
yes but this is how indians study can you guys recommend me a more detailed lectures?
@Cube2deth
@Cube2deth 3 жыл бұрын
@@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
@mariusz4742
@mariusz4742 8 жыл бұрын
Thanks a lot, that's so easy when you explained it :)
@pikapika8282
@pikapika8282 5 жыл бұрын
Awesome video! Thanks for posting, this has helped me a lot!
@rialaurent-hughes7191
@rialaurent-hughes7191 8 жыл бұрын
Thank you, that was perfect. Explained better than my lecturer
@latheefjunior
@latheefjunior 8 жыл бұрын
Bro, you've done a wonderful job here. Thanks!!!
@ghakol
@ghakol 3 жыл бұрын
thank you so much for this video!! i have a test on this in a few hours and this explanation was really helpful :)
@younusahmed23
@younusahmed23 7 жыл бұрын
hey thank you for this video it was extremely helpful and it helped me understand a complex concept in only 10 minutes. Awesome video
@a50x
@a50x 6 жыл бұрын
Great explanation, easy to understand, really helped me to clearly understand DP
@xlOogh0stoOlx
@xlOogh0stoOlx 9 жыл бұрын
Thank you so much. I have computer algorithm exam tomorrow and this video really helps me. You're the man.
@elyxthelynx
@elyxthelynx 6 жыл бұрын
This is really useful! Thank you for the video!
@achilles165
@achilles165 9 жыл бұрын
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.
@bernardoalvarenga2607
@bernardoalvarenga2607 6 жыл бұрын
Excellent explanation, great clarity. I've seen a video from CS50 on the subject that was a mess. This is great.
@maielshazly6054
@maielshazly6054 7 жыл бұрын
Your explanation is really clear. Thank you very much
@xxbighotshotxx
@xxbighotshotxx 8 жыл бұрын
Thank you Tushar, seriously, I think I'm going to pass my algorithm final tomorrow because of these videos
@amith89rm
@amith89rm 4 жыл бұрын
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
@sagnikrana7016
@sagnikrana7016 4 жыл бұрын
Hey Amith, I understood the approach. Could you help me explain why this method works?
@AssSlurry2998
@AssSlurry2998 4 жыл бұрын
Pause the video at 3:35 and see this intuition , 1) when first string is 'a' and second string is 'a' , the cell has 0 as its value , that is the minimum number of inserts/delete/edits =0 . so dp [ 1 ] [ 1 ] =0 2) when first string is 'az' and the second string is 'a' , for converting second string to first , 1 insert is required , so dp[ 2 ] [ 1 ] =1 3) When first string is ' a ' and second string is 'ab' , for converting second string to 1 , 1 delete is required ,i.e delete 'b' . so dp[ 1 ] [ 2 ]=1. Now comes the cell dp[ 2 ] [ 2 ] . If str1[ i-1 ] != str2[ j-1 ] There are 3 possible ways to do it . 1) Possibility 1 : Use dp [ 1 ] [ 2 ] , that is if i delete b from second string , both strings become equal , so if z is added to the first string , we can use dp [1 ] [ 2 ] that contains the number of deletions to make string first =string second . So we can just insert one element Z to string first to make them equal . 2) Possibility 2 : Use dp[2][1] ,that is if insert z in the second string , both strings become equal , so if i added b to the second string , we can use dp[2][1] that contains the number of insertions to make string first=string second . So we can just delete one element B from the second string to make first string =second string. 3) Possibility 3: use dp[1][1] , that is , if string 1 ='a' and string 2 ='a' , minimum number of edits required to convert string 2 to string 1 =0 . SO if z is added to the first string and b is added to the second string , we can just edit b in string 2 and make it z to make strings equal. Finally we assign dp[i][j] as the minimum of the 3 :) , hope it helps
@tanishq2766
@tanishq2766 3 жыл бұрын
Hey thank you so much! This was really what I was looking for!
@eliasmorag
@eliasmorag 7 жыл бұрын
Good job! It really helped me
@KameshwaranTheInsane
@KameshwaranTheInsane 7 жыл бұрын
I owe you so much Perfectly presented. You had explained this within 10 minutes Thank you very much...
@rahilgupta1244
@rahilgupta1244 8 жыл бұрын
Thanks a lot Tushar! Very well explained
@priyanksaxena18
@priyanksaxena18 6 жыл бұрын
Beautifully explained. Thank you.
@perfectfalse1
@perfectfalse1 2 жыл бұрын
THIS WAS A HUGE HELP. Thank you for posting this.
@chintalapativenkataramarahul
@chintalapativenkataramarahul 6 жыл бұрын
Thank you dude! Nice explaianation
@oborotsuki6sai
@oborotsuki6sai 6 жыл бұрын
Thanks a lot for the explanation!! So much easier to understand
@ahmedboutaraa8771
@ahmedboutaraa8771 3 жыл бұрын
shout out to you man. really empowering content.
@cadmonyuen6141
@cadmonyuen6141 9 жыл бұрын
You are doing a really good job. Keep up man.
@novicaovuka5480
@novicaovuka5480 6 жыл бұрын
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.
@amanbhandari349
@amanbhandari349 3 жыл бұрын
You learn code!!??? Wtf
@josegermanparra6064
@josegermanparra6064 3 жыл бұрын
Thanks for a clear and concise explanation!
@evergreen7781
@evergreen7781 3 жыл бұрын
I can say that, you have the best Dynamic Programming KZbin tutorial in the market ❤️❤️❤️
@Toxx98
@Toxx98 9 жыл бұрын
Thank you for your videos, helped me understand it properly.
@malvikark124
@malvikark124 4 жыл бұрын
Great explanation. Thanks so much!
@ankursuri3853
@ankursuri3853 6 жыл бұрын
This is the best explanation I have found sofar. Thanks so much Tushar! Keep up the good work.
@uditkanotra9393
@uditkanotra9393 3 жыл бұрын
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]).
@yuhua1994
@yuhua1994 7 жыл бұрын
Helpful video! Totally understand after watching your videos :)
@sarikaranjitkumar174
@sarikaranjitkumar174 4 жыл бұрын
Thank you for the great explanation!
@ts-gaming-29531
@ts-gaming-29531 8 жыл бұрын
Very good short video . Good job.
@ryan_forte2097
@ryan_forte2097 2 жыл бұрын
This was very informative and helpful. Thankyou!
@alvaro1121
@alvaro1121 6 жыл бұрын
Thank you my friend! Very clear explanation of the algorithm
@rulisastra
@rulisastra 6 жыл бұрын
Wow, great explanation... Thank you!
@afiyatiamaluddin9034
@afiyatiamaluddin9034 3 жыл бұрын
Thank you very much, this is my AHA MOMENT. This is what I'm looking for all this time.
@jarias14
@jarias14 8 жыл бұрын
Thank YOU for explaining this in detail.
@dimitrisdimitriou6969
@dimitrisdimitriou6969 8 жыл бұрын
Tushar! Awesome! Great job!
@prashantjindal8697
@prashantjindal8697 8 жыл бұрын
Your videos on dynamic programming are extremely helpful....!!! Great Job Tushar.....!!!!
@chilipeppero
@chilipeppero 8 жыл бұрын
Excellent friend, I could understand this algorithm, thanks a lot!
@monapanah
@monapanah 3 ай бұрын
Bravo! one of the best teachers in this field! thank you
@AnonymousDeveloper1
@AnonymousDeveloper1 7 жыл бұрын
You are awesome man, great explanation.
@masoomakram4270
@masoomakram4270 8 жыл бұрын
Awesome explanation... Finally I understood. Thank You.
@hopem6501
@hopem6501 6 жыл бұрын
Thank you so much. You really helped me understand :)
@logicraju
@logicraju 7 жыл бұрын
Awesome video, bro ! Was very useful !
@danielbogolin8880
@danielbogolin8880 7 жыл бұрын
Thank you so much. Keep up the good work! :)
@agrimasrivastava2060
@agrimasrivastava2060 8 жыл бұрын
Thanks a lot Tushar. One of the best explanations I came across. :)
@TheManawaha
@TheManawaha 8 жыл бұрын
Thank you, really helped me a lot :)
@nikkiv7919
@nikkiv7919 7 жыл бұрын
Thanks Tushar this is great
@umerwaqas5943
@umerwaqas5943 8 жыл бұрын
wonderfull way to teach. it was so difficult for before watching this. thanks
@ayanpaul27
@ayanpaul27 3 жыл бұрын
Short and crisp explanation.. Thank u so much... Finally i got to understand this
@Harow77
@Harow77 Жыл бұрын
Thanks sir, cleared all my doubts in a short time.
@ghensao4027
@ghensao4027 7 жыл бұрын
thank you dude. your explanation is very clear
@deepakkumarshukla
@deepakkumarshukla 4 жыл бұрын
Thanks bro! Much appreciate your effort.
@AntiochsAdvocate
@AntiochsAdvocate 2 жыл бұрын
Got stuck on this problem in an NLP textbook and this really helped tysm :)
@gururajraykar9254
@gururajraykar9254 3 жыл бұрын
Just awesome video. Was searching short video which i can learn this algorithm.
@yusniamaliah4522
@yusniamaliah4522 8 жыл бұрын
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..
@eshwareducationsolutions2091
@eshwareducationsolutions2091 8 жыл бұрын
this is the best explanations. Thanks much. Your implementation is very simple too. I really helped for my exam.
@dhanashreepawar9329
@dhanashreepawar9329 7 жыл бұрын
Good and clear explanation. Easy to understand!!!
@marinakantar8648
@marinakantar8648 7 жыл бұрын
Thanks a lot! It was very helpful :)
@tristangrobler4950
@tristangrobler4950 2 ай бұрын
This is really cool! 9 years since posting and it helped. Nice work!
@GlobalContentThatWeNeed
@GlobalContentThatWeNeed 5 жыл бұрын
Good explanation of Minimum Edit Distance Algorithm!
@Daniel-to5jd
@Daniel-to5jd 3 жыл бұрын
the best video i have found on this topic so far, you explain it better than in a paid coursera course
@vyshnavramesh9305
@vyshnavramesh9305 3 жыл бұрын
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.
@ashdavv
@ashdavv 7 жыл бұрын
Thanks for the videos .. Great explanation
@nischalguruprasad600
@nischalguruprasad600 7 жыл бұрын
Great video! Thank you very much
@quynhlq8832
@quynhlq8832 7 жыл бұрын
very easy to understand. Thanks a lot!
@jonesbrothers134
@jonesbrothers134 11 ай бұрын
Excellent video sir, Thanks a lot.
@AbdurRahman-mv4vz
@AbdurRahman-mv4vz 11 ай бұрын
Thank you for the helpful video.
@muthurajramalingakumar2361
@muthurajramalingakumar2361 4 жыл бұрын
Thanks for the upload! The intuition behind taking the Min of three cells would be helpful.
@antonioprocentese3253
@antonioprocentese3253 8 жыл бұрын
The best explanation ever! Thank you !!! :))))
@abhijithtk
@abhijithtk 9 жыл бұрын
I think this is one of the best explanations out there for this problem. Thanks much. Your implementation is very simple too. love it.
@YanuarTriAdityaNugraha
@YanuarTriAdityaNugraha 8 жыл бұрын
+Abhi Tk Absolutely, very easy to understand. Keep going.
@milesstephenson4873
@milesstephenson4873 6 жыл бұрын
Thanks, Tushar. Very clear explanation.
@dearn5900
@dearn5900 29 күн бұрын
Thank you for this video, you help me a lots
@zoyajaveed2186
@zoyajaveed2186 7 жыл бұрын
Thank you so much. Saved my time 😊
@PAIETES19
@PAIETES19 8 жыл бұрын
Best explanation on the internet! Thanks for the video
@vamsik6457
@vamsik6457 6 жыл бұрын
Thank you Tushar! So helpful.
@jeffhansen1554
@jeffhansen1554 2 жыл бұрын
Thank you so much for this vid!
Edit Distance - Dynamic Programming - Leetcode 72 - Python
21:00
Minimum Edit distance (Dynamic Programming) for converting one string to another string
28:22
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 143 М.
I Can't Believe We Did This...
00:38
Stokes Twins
Рет қаралды 84 МЛН
Was ist im Eis versteckt? 🧊 Coole Winter-Gadgets von Amazon
00:37
SMOL German
Рет қаралды 35 МЛН
Дибала против вратаря Легенды
00:33
Mr. Oleynik
Рет қаралды 5 МЛН
That's how money comes into our family
00:14
Mamasoboliha
Рет қаралды 8 МЛН
Coin Changing Minimum Number of Coins Dynamic programming
8:33
Tushar Roy - Coding Made Simple
Рет қаралды 485 М.
Edit Distance of two strings - Real world application
18:25
Gaurav Sen
Рет қаралды 69 М.
0/1 knapsack problem-Dynamic Programming | Data structures and algorithms
27:31
Jenny's Lectures CS IT
Рет қаралды 1,1 МЛН
Lowest Common Ancestor Binary Tree
11:08
Tushar Roy - Coding Made Simple
Рет қаралды 250 М.
Binary Search : Median of two sorted arrays of different sizes.
24:48
Tushar Roy - Coding Made Simple
Рет қаралды 540 М.
2 1 Defining Minimum Edit Distance 7 04
7:05
From Languages to Information
Рет қаралды 14 М.
Text Justification Dynamic Programming
15:31
Tushar Roy - Coding Made Simple
Рет қаралды 142 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 614 М.
I Can't Believe We Did This...
00:38
Stokes Twins
Рет қаралды 84 МЛН