Bellman-Ford in 5 minutes - Step by step example

Поделиться
HTML-код
  • Опубликовано: 29 ноя 2024

Комментарии • 471

  • @triandot
    @triandot Год назад +363

    7 years ago, better explanation than any modern source

    • @saikatsaha1907
      @saikatsaha1907 11 месяцев назад +14

      Still better than anything else from 2023 😂

    • @eliokuster4915
      @eliokuster4915 10 месяцев назад +2

      yeah for real

    • @q1bb0
      @q1bb0 9 месяцев назад +2

      now, 8 years ago

    • @micycle8778
      @micycle8778 7 месяцев назад +3

      because every mf decides to hide the algorithm behind opaque notation

    • @sub-hh5qg
      @sub-hh5qg 5 месяцев назад +4

      9 and still true…

  • @jrumac
    @jrumac 5 месяцев назад +15

    you got me through my undergrad DS&A course and now i've come back to you for interview prep. thank you!!!

  • @BharatSingh-zk8lx
    @BharatSingh-zk8lx 8 лет назад +762

    Tomorrow is my exam and this has saved my day . Thanks a lot man🙌

  • @JovanaaaSK
    @JovanaaaSK 7 лет назад +27

    Thank you so much ! It's just pretty amazing how we spent 2 sessions of 2 hours in an amphitheatre trying to learn this and turn the algorithm by following the literal code, and here I got it in literally 5 minutes. I'm so eternally grateful.

    • @alexgarrett277
      @alexgarrett277 Год назад +5

      I love how universities teach computer science like social studies

  • @mehdibadaoui1658
    @mehdibadaoui1658 4 года назад +23

    it's unbelievable how well you explain the algoritms

  • @nerdalert-y3t
    @nerdalert-y3t 14 дней назад

    You are a saint. Your small lessons provide more value than several hours of lecture by my prof. Keep it up.

  • @forthehomies7043
    @forthehomies7043 7 месяцев назад +2

    Only video on Bellman-Ford that cemented my understanding.

  • @HowlingDeath
    @HowlingDeath Месяц назад +1

    You're the best algo teacher I have ever seen sir

  • @lunaticnomad0
    @lunaticnomad0 5 месяцев назад

    This guy is the best in this kind of content, clear speech with concise teachings.
    🙏 BLESS 🙏

  • @o8XOX8o
    @o8XOX8o 7 лет назад +3

    Wow my professor took about 20min to explain this and I didn't really get it. I thought it was hard, but after watching your video in 1/4th the time I am able to explain to others how to run the algorithm, and truly understand it. Turns out it isn't hard at all - just need someone good like you to explain it! Thanks a ton.

  • @huzaifamohsin
    @huzaifamohsin 5 лет назад +5

    I've have exam in half an hour and here I am watching this video! Thanks Man!

    • @whogotpwned
      @whogotpwned 7 месяцев назад

      Hope you managed to pass 👍😀

  • @mazenessam8326
    @mazenessam8326 2 года назад

    i was litterly in a middle of a half an hour exam and i didnot know what was this algorithm i opened youtube and found you and litterly in less than 2 mins i understood it and solved the exam thanks bro ❤❤

  • @mingHiewNN
    @mingHiewNN 8 лет назад +31

    Thank you so much for your fantastic work! I found learning these techniques by merely reading textbooks and listening to university lecturers pretty bland and counter-intuitive, but fortunately your visualized examples have given me a much clearer picture. in fact I started to understand the all the previously incomprehensible texts and pseudo-codes just after having seen your videos, and I would very much appreciate if you have any plans in the future to share further videos on NP-complete problems and approximation algorithms. Have a nice day!

    • @MichaelSambol
      @MichaelSambol  8 лет назад +7

      More on the way, thank you for watching.

  • @jix2bro
    @jix2bro Год назад

    I've never seen better explanation about Bellman-Ford than this video. Thanks a lot!

  • @Anushkumar-lq6hv
    @Anushkumar-lq6hv 2 года назад +1

    I finally understood Bellman-Ford. Thanks for the working example.

  • @nksdp9776
    @nksdp9776 9 лет назад +2

    You have the lightest and best understandable pseudo-code i've seen !
    Thanks a lot !

  • @버그헌터_기브르
    @버그헌터_기브르 2 года назад

    jeez if the professor at our uni could explain it this way. simple and straight forward to the point. thanks a lot

  • @estebancarrasco5823
    @estebancarrasco5823 6 лет назад

    I have a discrete mathematics test coming up, and thanks to you, now i understand better. Thanks¡

  • @SatyamEdits
    @SatyamEdits 4 года назад +1

    thank you so much...!!! 😢😢 i had tears in my eyes....it cleared completely all my doubts...

  • @jaeyongim
    @jaeyongim 2 года назад +1

    Straightforward and clear demonstration of the algorithm. Your video helped me a lot. Thanks :)

    • @MichaelSambol
      @MichaelSambol  2 года назад

      You are welcome! Thanks for watching.

  • @mayankbaraskar
    @mayankbaraskar 8 лет назад +3

    Thanks a lot man...I am going for exams and these 5-minute video will definitely add some marks to my paper...

  • @RandomShowerThoughts
    @RandomShowerThoughts 4 месяца назад

    I think this might be one of the best explanations I've seen, I just couldn't understand why we'd need to perform more than 1 iteration. But it makes sense because we don't know how to learn the node, hence, the requirement for more edges. We may finish early, but we need to discover all the possible shortest paths before that.

    • @MichaelSambol
      @MichaelSambol  4 месяца назад

      This should help too: github.com/msambol/dsa/blob/master/shortest_path/bellman_ford.py

  • @phjnarthana
    @phjnarthana 6 лет назад +1

    This helped me a lot with my exams. Thanks a lot brother. You are a savior 😅

  • @cyprianblunt1783
    @cyprianblunt1783 7 лет назад

    Thanks for the video. It'll help me get through my homework and (maybe) final. I'll show this to anyone else stuck on this problem.

  • @leonleng7814
    @leonleng7814 2 года назад

    Thank u so much. It's the best Bellman Ford Descrption Video I've ever seen!

  • @deep.space.12
    @deep.space.12 2 года назад +23

    Instead of only outputting the distance, it would be nice to add that, for each node one can keep track of the parent node where the current shortest distance is found, then traverse backwards from the destination to the source to obtain the shortest path.

    • @petosigut2271
      @petosigut2271 9 месяцев назад

      Very important, it is also missing in the pseudocode, the prev attribute is set to nil initially, but not changed in the update procedure

  • @brandoncazares8452
    @brandoncazares8452 Год назад

    This has very much saved my day for my final tomorrow. Thanks, Michael.

    • @MichaelSambol
      @MichaelSambol  Год назад +1

      Glad I could help! Good luck on your final, Brandon.

    • @brandoncazares8452
      @brandoncazares8452 Год назад

      @@MichaelSambol Fantastic Michael. This video's helpful for me and glad I watched this.

  • @nightmareblocks
    @nightmareblocks 6 лет назад

    Bless. Thank you so much. This makes WAY more sense than the pitiful amount of explanations on it in my class. I have my final in an hour and a half and you might have just saved me a world of hurt.

  • @D3ebK
    @D3ebK 9 лет назад +3

    Very eloquently demonstrated, Michael!

  • @YousraBenzeghiba
    @YousraBenzeghiba 8 лет назад +2

    I am headed to my exam rightnow ...You saved my life

  • @ajnabee01
    @ajnabee01 2 года назад

    New knew Bellman Ford algorithm was so easy. Great content man 🔥

  • @abdullahkhalid9581
    @abdullahkhalid9581 6 лет назад +1

    Thank you! Already shared your channel with my friends. We have design & analysis of algorithms exam tomorrow and your videos are short and precise.

  • @gargnakshatra
    @gargnakshatra 4 года назад

    Thanks Very Much, I Really Appreciate It. I have watched many videos on this topic in the last hour but You explained the BEST. THANKS, Michael!

  • @chadkrause6574
    @chadkrause6574 7 лет назад

    Good, easy, short explanation. These algorithms aren't hard, but everyone makes them really hard by making videos that are way too long and with unnecessary information. Show the algorithm first, then the detail. Good job!

  • @FaizanAli-nl5ll
    @FaizanAli-nl5ll 6 лет назад

    Great excercise I like it..it's very useful for us and everybody...everybody can see this and learn this excercise easily from this channel.

  • @abhichakladar5279
    @abhichakladar5279 5 лет назад +1

    If only lectures were as easy and straightforward as your tutorials

  • @jameshaynes5954
    @jameshaynes5954 4 года назад +3

    No negative cycle detection int this video, which is a key part of Bellman Ford!!!

  • @sitadevimuthkhod3034
    @sitadevimuthkhod3034 6 лет назад +33

    Hey Michael!
    Your videos are really time saving and awesome! It would be a great help if you made such videos on string matching algorithms like KMP, Rabin Karp, Finite Automata and Naïve as well!

  • @ekaterinakurochkina8780
    @ekaterinakurochkina8780 3 года назад

    Thank you very much. I couldn’t find anything useful on Russian, so I found this video and it help me

  • @TransportFever2Live
    @TransportFever2Live 6 лет назад +2

    Thank you, relaxing edges seems now so easy when drawn instead of all these number and steps in algorighms!

  • @gazebo543
    @gazebo543 4 года назад

    Thank you! much better and simpler than so many ppt slides

  • @sachinmagdum9796
    @sachinmagdum9796 6 лет назад +16

    Nice!
    You may want to add how to check for negative-weight cycles.

    • @yitzchakmeltz1309
      @yitzchakmeltz1309 2 года назад

      for sure something that's missing from this video. Especially when this is a big advantage for this algorithm

  • @Sulerhy
    @Sulerhy 5 месяцев назад

    this is absolutely the best explanation for me who does not come from CS school. Thank you, now I can beat them lmao

  • @kellyharper753
    @kellyharper753 9 лет назад

    Thaaaaaaaaanks man............you saved my life...it's the best explanation of bellman-ford algo for me

  • @josefinkarlsson3712
    @josefinkarlsson3712 6 лет назад +1

    I LOVE YOUR VIDEOS!! I learn so much when you explain short and simple- THANK YOU!

  • @slahfaguira3138
    @slahfaguira3138 7 лет назад

    Tomorrow is my exam and this has saved my day . Thanks a lot man :)

  • @toby0622
    @toby0622 3 года назад

    Clear and easy to understand, great work. The only thing I'm concerning is that the speaking is a little bit to slow.

  • @iaa423
    @iaa423 Год назад +2

    Great video for a refresher!

  • @anerdwitdacamera204
    @anerdwitdacamera204 8 лет назад +9

    You must have spent a huge amount of time on drawing all these pictures. thank you so much!!!

  • @zackkite
    @zackkite 9 лет назад +2

    Excellent explanation. Very concise.

  • @doomgao3571
    @doomgao3571 2 года назад

    This is real eduation. Today's over 1k students' CS class with low pass rate can only be called a filter, it is not a class!

  • @TungTran-yp5yf
    @TungTran-yp5yf Год назад

    i've watched your vid for about 3 mins or something and that makes me understand the algo more thoroughly than what my professor did at the previous class for an hour! Lmao =DD

  • @pasanmadu6495
    @pasanmadu6495 Год назад

    A comprehensive short and sweet video
    Than you!!!

  • @-luca9982
    @-luca9982 5 лет назад

    You are a god for every cs student! All hail Michael!

  • @tianzewang6734
    @tianzewang6734 7 лет назад

    Wow that's amazing. 5 mins video wins 20 slides of our lecture

  • @ubaidurrehman4377
    @ubaidurrehman4377 6 лет назад

    Thanks a lot man, Tomorrow is my exam you have saved my day ......

  • @shando_tube
    @shando_tube 5 лет назад

    nothing will ever beat this vid

  • @lynam5464
    @lynam5464 5 лет назад

    Very very veryyyyy great for my prepare to exam tomorrow. Thank you!

  • @andreialeksanian7334
    @andreialeksanian7334 3 года назад

    better than my uni lecture. Thanks!

  • @Mark-fc7tu
    @Mark-fc7tu 4 года назад +1

    Very clear and informative. Thank you.

  • @AdityaNand97
    @AdityaNand97 7 лет назад

    Great Illustration Sir. Thanks for the video...!

  • @charmingzhang8682
    @charmingzhang8682 Год назад

    Love this! I've been stuck for hours

  • @ThefamousMrcroissant
    @ThefamousMrcroissant 6 лет назад +20

    Kinda forgot the cycle detection there lad. If the algorithm still finds a better path after n-1 iterations a negative cycle must exist. Which is one of the great powers of Bellman-ford's.

    • @it41tanmayaron26
      @it41tanmayaron26 3 года назад +1

      No algo can find shortest distance if there exists a negative cycle

    • @kodyappleton6892
      @kodyappleton6892 3 года назад +4

      @@it41tanmayaron26 Yes but it can detect one and return a message stating that one exists and that the shortest path is -∞

  • @子72
    @子72 Год назад

    Thank u. u r the god of teaching algorithm.

  • @Noah-jz3gt
    @Noah-jz3gt 3 года назад

    this video helps a lot for my understanding.. finally...

  • @Guiguilamster
    @Guiguilamster 7 лет назад

    You juste saved me one hour before my exam, thank you so much :D

  • @sandunrajapurage6493
    @sandunrajapurage6493 3 года назад

    Woow, You saved lot of time. Thank You very much.

  • @Lamya1111
    @Lamya1111 2 года назад

    really good explanation! thank you, Michael.

  • @sanketsinha8933
    @sanketsinha8933 8 лет назад

    thanks so much your method of teaching is very detailed..thanks again for making this video!

  • @leeamraa
    @leeamraa Год назад

    thank you! great tutorial!!! Please keep doing what you do. a suggestion to add how to find/check on the negative cycles.

    • @MichaelSambol
      @MichaelSambol  Год назад

      I should have mentioned that, apologies. Take a look at the code here, it should help: github.com/msambol/youtube/blob/master/shortest_path/bellman_ford.py#L44-L52. Thanks for watching!

  • @JosephKJ
    @JosephKJ 8 лет назад +14

    Cant be better. Thanks a lot.

  • @oscarhenry7412
    @oscarhenry7412 Год назад

    Big thumbs up. Very well explained!

  • @crazygeekman4068
    @crazygeekman4068 5 лет назад

    Vidéo de qualité avec des sous-titres en Français écrits avec soin. Merci :)

  • @mouradmabrouk7328
    @mouradmabrouk7328 11 месяцев назад

    wow your explanation is the best bro keep it up

  • @chrysoulabenou5843
    @chrysoulabenou5843 2 года назад +1

    Thanks! Great and brief video :)

  • @tioman42
    @tioman42 Год назад

    Exam in 2 hours. Saves my day!

  • @mdellertson
    @mdellertson 7 лет назад

    Great explanation, very easy to understand. Thanks so much!

  • @nidhishukla_iitiankgp
    @nidhishukla_iitiankgp 3 года назад

    thanku sir much simpler explanation and exact point

  • @Saurav192
    @Saurav192 8 лет назад

    The best video yet.....

  • @toufiqulislam5637
    @toufiqulislam5637 9 лет назад

    Very nice explanation. Thanks a lot. Thumbs UP.

  • @shliang
    @shliang 9 лет назад +5

    Great videos, I encourage you to make a full library of these

  • @william0377
    @william0377 6 лет назад

    genius, its clear and easy to understand, thanks man

  • @privateaccount4460
    @privateaccount4460 Год назад

    Quick note others pointed out: Pseudo code forgets to actually implement prev. (My guess is, during the confusion of trying to make procedure update look mathematically formal instead of writing understandable code): instead of a min, equivalently do:
    sum = dist(u) + l(u, v)
    if sum < dist(v), then
    dist(v) = sum
    rev(v) = u
    (don't dist(u) +l(u, v) potentially twice per update, optimize!!!)

  • @stephenlasky9348
    @stephenlasky9348 9 лет назад

    great video, short and to the point

  • @sarveshpandey1125
    @sarveshpandey1125 6 лет назад

    It's such a perfect explanation. Please make a video on Master's Theorem.

  • @pawesosnowski253
    @pawesosnowski253 5 лет назад

    Awesome simple explanation, thanks!

  • @michaliskaseris2467
    @michaliskaseris2467 7 лет назад

    Best tutorial out there! Good work mate!

  • @trevorg5938
    @trevorg5938 7 лет назад

    i have such a limited attention span you are perfect!

  • @deepaksinghpana5097
    @deepaksinghpana5097 7 лет назад

    Thank you soo much man. You saved me.. (tomorrow is my exam)

  • @marcorivera4776
    @marcorivera4776 6 лет назад

    Clear and concise video, thanks!

  • @kutilkol
    @kutilkol 3 года назад +2

    1:37, the picture is good (red arrow representing the inspected edge B->A), but the narrative is somewhat misleading. "Getting to B..." , more likely getting to edge B->A, we see that dist(B) = inf, so dist(A) don't get updated.
    Nice vid, tho, tx

  • @maingameapaman
    @maingameapaman 5 лет назад

    finally! a non indian accent bellman ford video!!!

  • @debojyotisaha
    @debojyotisaha 8 лет назад

    Thanks sir for giving this great explanation .

  • @folksgames7047
    @folksgames7047 8 лет назад

    Fast accurate videos. Thank you!

    • @MichaelSambol
      @MichaelSambol  8 лет назад

      +FolksGames Glad you enjoyed. Thanks for watching.

  • @AgPower1000
    @AgPower1000 9 лет назад +12

    In the algorithm you have a prev() table that you don't update next neither you use it on the animation. Other than that great job

  • @harshdhaundiyal2241
    @harshdhaundiyal2241 7 лет назад

    Great Video 🙌🙌🙌 Thanks It's been really helpful

  • @tnvmadhav2442
    @tnvmadhav2442 7 лет назад

    It is really good and concise ! Thank you

  • @tored7656
    @tored7656 8 лет назад

    Nice greetings from Germany. Its a very good video :) Thank you

  • @avinashsingh4989
    @avinashsingh4989 8 лет назад

    It's an awesome video mate. Thank you very much..!

  • @Jake_2903
    @Jake_2903 3 года назад

    you can ierate one more time after V-1 iterations, and if any edge is relaxed there is a negative cycle and yozu can return None, or neginf or whatever, this way it will work on graphs with negative cycles