Edit Distance between 2 Strings | The Levenshtein Distance Algorithm + Code

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ก.พ. 2025

ความคิดเห็น • 72

  • @chadsmith71
    @chadsmith71 ปีที่แล้ว +13

    Great video. I watched 2-3 other videos on this same problem, but I still struggled to understand the algorithm. Your explanation was clear and easier for me to understand. Well done.

  • @SIARSEDIG
    @SIARSEDIG 29 วันที่ผ่านมา

    Thank you for explaining in such a clear and concise way, I had problems with other videos like many other people, but you saved us! Thank you!

  • @annas8308
    @annas8308 27 วันที่ผ่านมา +1

    Love your way of teaching, so clear and easy to understand. Thank you and Keep up the good works! :D

  • @amarieelohor7319
    @amarieelohor7319 ปีที่แล้ว +5

    Explicit explanation. I got confused using a different video; but this helped me understand. Thank you!!!!!!!!!!!!

  • @Stelios.Posantzis
    @Stelios.Posantzis 2 ปีที่แล้ว +3

    Excellent presentation. It's the first one I've seen where one can quickly understand the process. One still needs to make the mental effort to convince oneself that the method does indeed work in all situations. If the demonstration of the method, however, is enough for some to assure them that it works, then working out a proof that it does can be deferred.

  • @Ali-zg4fy
    @Ali-zg4fy ปีที่แล้ว +1

    I literally couldn't understand the UCSD course and your video helped me out big time. Recommending this to anyone who struggles tbh

  • @ecliipvzz
    @ecliipvzz 9 หลายเดือนก่อน +4

    Thankyou so much for the explanation!! I have my finals next week and this helped a lot.

  • @porrakroth
    @porrakroth 2 ปีที่แล้ว +2

    Excellent explanation! I was trying so hard to understand how this algorithm works and now it's clear, thank you very much

  • @angeltran381
    @angeltran381 11 หลายเดือนก่อน +1

    Thank you. At first, I feel difficult to understand the problem. Thanks to your video, it is clear and easy to implement.

  • @streetcube-x3h
    @streetcube-x3h 2 ปีที่แล้ว +4

    Thank you so much for this video. It really helped me to understand how the Levenshtein distance works!

  • @zekicaneksi
    @zekicaneksi 7 หลายเดือนก่อน

    even if i understood it, you made a fanstastic job. thanks my man

  • @annvilprince5083
    @annvilprince5083 2 ปีที่แล้ว

    Gawdddd the struggle i took to understand this in class😭😭 ....... thanks a lott sir

  • @TP-rs2un
    @TP-rs2un ปีที่แล้ว +1

    Thank you for this video, it has tremendously helped me understand this problem for my algorithms class.

  • @swatiujgare8921
    @swatiujgare8921 ปีที่แล้ว

    Excellent Explanation...your video is best to understand levenshtein distance algo

  • @pavankumar-of4ew
    @pavankumar-of4ew หลายเดือนก่อน +1

    neatly explained

  • @og1kenobi973
    @og1kenobi973 10 หลายเดือนก่อน +2

    You, sir, are a LEGEND!

  • @rezaderakhshan1732
    @rezaderakhshan1732 2 ปีที่แล้ว +1

    Thanks for making this video it is so helpful
    Good luck dude

  • @smilingworld9647
    @smilingworld9647 5 หลายเดือนก่อน +1

    thank u brother you saved my exam
    🌹🌹🌹🌹

  • @egdcuyagecuysadgcuys
    @egdcuyagecuysadgcuys 3 ปีที่แล้ว +2

    Best explanation. Thank you!

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Glad you liked it! Please consider subscribing for more such videos!

  • @hosseinsafari7514
    @hosseinsafari7514 2 ปีที่แล้ว +1

    One of the best explanations, thanks :)

  • @thecurlykale
    @thecurlykale 2 ปีที่แล้ว

    thanks for the great explanation! after watching a few videos on this question, i finally get it.

  • @obarlanytska3051
    @obarlanytska3051 9 หลายเดือนก่อน +1

    cool video with brilliant explanation.

  • @KNO476
    @KNO476 ปีที่แล้ว +1

    for the worked example starting at 10:17, in my opinion the explanations only work if we try to convert word2 to word1.

  • @ioulios12
    @ioulios12 3 ปีที่แล้ว

    Thank you! You are much better than my teacher

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว +1

      It's an honour to hear that! Thank you!

  • @umadas1831
    @umadas1831 3 ปีที่แล้ว +1

    Very nicely explained, Sir..

  • @Ihang-u9v
    @Ihang-u9v ปีที่แล้ว

    17:13 i could not understand how we can perform replace and insert ?
    min of the (Neighbouring elements +1 ) so it is either replae vs insert. But
    To convert "re" to "d" the way i see is replace 'r' by d and delete it.
    Or am i missing something?

  • @정보규-q4l
    @정보규-q4l 2 ปีที่แล้ว +1

    Thanks for video. you're the best

  • @gabrielyassunaga3447
    @gabrielyassunaga3447 3 ปีที่แล้ว +2

    Very nice video bro!

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Thank you! Be sure to subscribe for more videos!

  • @akshanshbhandari7619
    @akshanshbhandari7619 2 ปีที่แล้ว

    Nicely explained...!
    Gud work..!

  • @BlokeBritish
    @BlokeBritish 2 ปีที่แล้ว +1

    02:49 why not check the 1st index ?
    why the last .

  • @youthought878
    @youthought878 ปีที่แล้ว +1

    It's simple. Create a 0th cell in the top right and but 1-.... for each word to create rows/columns. Once you have done that its super easy: Look at the top, top left, and left column from where the first open cell. Whatever the lowest number you see is you add 1 to it and that's your answer. In the case that the letters correspond ("e" and "e") use whatever value is in the top left column and then continue to the next combo. Awesome video though

  • @anaresthiana
    @anaresthiana 4 ปีที่แล้ว +1

    Thanks for the great explanation

    • @JyotinderSingh
      @JyotinderSingh  4 ปีที่แล้ว

      Thank you! Be sure to subscribe for more content!

  • @jasonzavaglia
    @jasonzavaglia 8 หลายเดือนก่อน

    Best explanation I've seen on it though, thanks!
    Just wanted to point out though that there is an off-by-one error in the code. The for loops need to be up to

  • @孙逸方
    @孙逸方 4 ปีที่แล้ว +2

    Effective solution.

    • @JyotinderSingh
      @JyotinderSingh  4 ปีที่แล้ว

      Glad it helped! Remember to hit the like button and subscribe for more content!

  • @mohammadramadhoni3285
    @mohammadramadhoni3285 ปีที่แล้ว +1

    Its very great explanation, im very understand it now

  • @musings2134
    @musings2134 4 ปีที่แล้ว +2

    Thanks for making this video. I liked that you added replace, delete, insert,current position in a small grid on the bottom left. It helps visualization.
    Btw what software do you use for your digital pen?

    • @JyotinderSingh
      @JyotinderSingh  4 ปีที่แล้ว +1

      I'm glad you liked the video! I use procreate on iPad for the visuals

    • @musings2134
      @musings2134 4 ปีที่แล้ว +1

      @@JyotinderSingh thanks!

  • @muslimahmukbang417
    @muslimahmukbang417 ปีที่แล้ว +1

    Really good explanation! Thank you so much!

  • @jjque322
    @jjque322 ปีที่แล้ว

    Exellent explanation!!!

  • @aarushisharma7856
    @aarushisharma7856 8 หลายเดือนก่อน +1

    Thanks a lot!!!

  • @oxymoron6701
    @oxymoron6701 3 ปีที่แล้ว +1

    This is only correct iff the costs for all operations are the same and their cost is one. Those are two big assumptions. It's not because there's a mismatch that you can just add a one automatically.

  • @AshishSharma-wj4jz
    @AshishSharma-wj4jz 2 ปีที่แล้ว

    nice explanation Jyotinder. I would like to more about the coding. Do you have some material I can look to understand, how you execute the same.

  • @Kidpunk98
    @Kidpunk98 3 ปีที่แล้ว +2

    Hi there! Great explanation. I don’t understand how we know that the diagonal cell is a “replacement” I get the logic for insertion and deletion, but not the replacement.

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Hey, the logic is that when you replace a letter - you basically match the last letter of the the two words by replacing one of them. This reduces the sub problem to the rest of the word that is to the left of the last two letters (which now match after the replacement). Now, we use the DP table to find the solution to this sub problem (of transforming the remaining words). The solution to this problem lies in the upper left diagonal cell of the current cell in the table. Why is that? Because if you remove the last letter from both the words - that's where you end up. Try re-watching the white board explanation in the video where I explain this.

    • @Kidpunk98
      @Kidpunk98 3 ปีที่แล้ว

      @@JyotinderSingh Wow, thanks for the fast reply! Really appreciate it!

  • @janlugtmeijer4347
    @janlugtmeijer4347 3 ปีที่แล้ว +2

    Thank you!!

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Glad it helped you out! Please consider subscribing for future content!

  • @nmnjn
    @nmnjn 4 ปีที่แล้ว +2

    Thanks bro! 💪🏻

    • @JyotinderSingh
      @JyotinderSingh  4 ปีที่แล้ว

      Glad to be of help bro! ♥♥♥

  • @engabeer
    @engabeer 2 ปีที่แล้ว

    Thanks great explanation

  • @TormodSteinsholt
    @TormodSteinsholt 3 ปีที่แล้ว +1

    At 22:23 I didn't understand why the [2,7] cell became 6 instead of 5. Why did it pick the 6 from the top-left instead of 5 from the left? Surely, the lowest number was the 5 to LEFT of [2,7], not the 6 from the ABOVE-LEFT.
    I thought we would always choose the lowest number to make sure that we followed the cheapest path (least number of operation) to get to the state that cell represented.

    • @JyotinderSingh
      @JyotinderSingh  3 ปีที่แล้ว

      Hi, if you look closely - that case is of a MATCH. It means we don't need to perform any operations (to convert e to e) and we can directly look at the remaining sub problem (which is converting 'replac' to 'd'). That sub problem is represented by cell [1,6].
      Hope this helps.

  • @deepikasingh3122
    @deepikasingh3122 ปีที่แล้ว

    but sir, this is not levenshtein algorithm. coz for substitution it adds 2

  • @Popdad
    @Popdad 3 ปีที่แล้ว +1

    Hi Jyothi, I was able to follow the example and explanation and had same matrix as per your explanation. Want to understand how you concluded that minimum number ops will be4? How can I find out required operations from the DP table?

  • @trysha2340
    @trysha2340 ปีที่แล้ว +1

    Thank you

  • @anuragchowdhury4034
    @anuragchowdhury4034 3 ปีที่แล้ว

    How did you get the grid? I don't understand

  • @armellekadia4997
    @armellekadia4997 4 ปีที่แล้ว +2

    thanks you!!!

    • @JyotinderSingh
      @JyotinderSingh  4 ปีที่แล้ว

      Glad you liked the video! Be sure to subscribe for more!

  • @ritwik121
    @ritwik121 4 ปีที่แล้ว

    hi sir in the insert operation why the target string is remaining the same ? why we are only reducing the source string by one character?

  • @janogashoamatalaah7764
    @janogashoamatalaah7764 10 หลายเดือนก่อน

    thank you

  • @kutilkol
    @kutilkol 3 ปีที่แล้ว

    you have the first row wrong. to match empty string on text takes 0 cost

  • @airsheebs
    @airsheebs 3 ปีที่แล้ว +1

    nice!

  • @tharuushi
    @tharuushi 3 หลายเดือนก่อน

  • @ragnarlothbrok367
    @ragnarlothbrok367 ปีที่แล้ว

    I dont understand a shit, why e to e is not zero? Why any letter to any letter is not one? Nothing makes any sense

  • @hind8426
    @hind8426 3 ปีที่แล้ว +1

    Best explanation!! Thank you