Bellman-Ford Algorithm Single Source Shortest Path Graph Algorithm

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

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

  • @tirushma
    @tirushma 8 лет назад +40

    Score GATE AIR 301 , DAA university topper, Acknowledgement goes to Mr.Tushar Roy. Thank you so much sir.
    You made Data Structure And Design And Analysis Of Algorithm so easy

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

      +Tushar Roy thank you so much again

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

    Man, we really need to play your videos during lecture. Talk about fantastic instruction. Your channel is really my go-to source now

  • @T1G5
    @T1G5 7 лет назад +1

    Your videos are the clearest tutorials I've found, and you cover so many different algorithms - thank you.

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

    Excellent work sir: After all these days, I really found that implementing graphs through programming is very easy....you made it so clear. Thank you :-)

  • @chrysanthesky
    @chrysanthesky 7 лет назад +2

    Really love your videos!Your enthusiasm and will to teach is pretty much evident through your videos.Thank you!

  • @vyassathya3772
    @vyassathya3772 7 лет назад +64

    Shouldve watched this on valentines day. Gotta keep the distance between You and We small

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

      so on average we are taking v-1 times for relaxing edges from source.So why can't i processes those edges from source itself.It will take |E| time complexity only??

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

    Compared to other 4-5 mins videos which also try to explain this algorithm. This video is longer than those but explains it far more clear than all other videos. GREAT WORK!!!

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

    You did the research instead of us and reduced our time. Thank you Tushar. Millions of hours reduced because of your research.

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

    Have my daa exam day after tomorrow. This video helped me complete an imp topic in a span of 20 mins. Thank you!

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

    Been looking around for exactly this kinda video for so long. Everything at one place, thanks mate!

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

    excellent...ur approach of teaching is excellent. directly gets corelated to code implementation ( maps, parents etc.) thanks..

  • @srudancer1
    @srudancer1 8 лет назад +26

    IT would have been nice if we followed the same suit as the Dijkstra and made the labels as A, B, C instead of 0,1, 2 here.. Given that distance is also numbers, it is a little confusing.. Great algorithm videos.. Thanks

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

      waste fellow tushoraaaan yak thu he is convincing all intelligent people then wat abt less minded idiot videos

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

    Another excellent tutorial.
    Still looking forward to deeper explanation of Suffix Tries, specially Ukkonen's and probably Suffix Automata.
    I would be glad to hear about Dinic's max flow too.
    Great again! :)

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

    Very helpful even after 7 years

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

    I really like your simple teaching

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

    Every video is a gem sir.

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

    Thanks a lot. The most comprehensive lecture on belman ford :)

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

    thanks for explaining cleary this algorithm. I had confusion regarding v-1 iterations thanks for clearing it.👍

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

    The ith (1 indexed) iteration computes shortest distance with atmost i edges in between source vertex and any other vertex. That is why i runs from 1 to V-1. The V-1 th iteration will consider the shortest distance from source vertex to the any other vertex, with atmost V-1 edges in between.

  • @Max-ke7pq
    @Max-ke7pq 8 лет назад

    Thank you! This video helps me to implement Bellman-Ford as generic class in Java.

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

      so on average we are taking v-1 times for relaxing edges from source.So why can't i processes those edges from source itself.It will take |E| time complexity only??

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

    Best algorithm lecture i've ever watched on youtube thankyou !

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

    How to understand the last iteration helps us find negative cycle in graph -
    Think like this, assume graph is V = 10 vertices.
    If a negative cycle exists, it must contains vertices this means you will go through the negative cycle AT LEAST ONCE.
    What does this mean ?
    This means the negative cycle will cause a change somewhere before the V-1 iterations or in the V-1 th iteration ( if entire graph is negative cycle )
    Hence the final iteration uses the idea that somewhere earlier in the V-1 iterations , one of the calculations for shortest path became INCORRECT.
    Hence the vertex that got updated by the negative cycke , will keep propagating this "disruption" in every further relaxation of all its neighbours in all subsequent iterations.
    This means that if you were to carry out more than V iterations , all subsequent iterations would have a change somewhere due to this propagation.

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

    Dear, from my understanding, it wont make any differnce, if order of edges taken as different at 13:10 minute of video explaing resson of vV1 times of algorithm. It would take V-1 times to run algorithm, because to get the shortest path in this particular example, all 3 edges(V-1) are involved. It can be appreciated from the algo, only atmost N edges can be added to the path after running the algorithm N times.
    Kindly correct, if I am wrong.

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

    Space complexity should be O(E), not O(V). E>V. We need to store every edge to iterate through them.

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

    You should use vertices name as a, b, c, etc and weights as 1, 2, 3 etc, using both numeric can confuse many people!

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

    love you man, really like your teaching, thanks a lot, cheers

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

    Best vedio for Bellmenford.....Thankuuu

  • @RohitVerma-sg1uz
    @RohitVerma-sg1uz 5 лет назад

    U r great man...........Thanks a lot...Wish i could withdraw my college fees Give it to you...

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

    sir that was a nice video for understanding the concept...But the graph that you used initially did change after some time before u applied the first iteration plzz check....

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

    The if statement of your relax method and the method itself are missing closing brackets.
    Anyways good explanation, keep up the good work!

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

    excellent video ...enjoyed watchiing it

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

    great explained......!!!!

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

    sir u said that to reach 1 to zero the shortest path is 4,but sir if we move from 0 to 2 it will take 5 and from 2 to 1 it takes -3 so 5+(-3)=2 and this is the shortest path to reach from 1 to 0.

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

    Very nice explanation! :) little suggestion, just improve video quality.

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

    Good explanation. It was a little disorienting when you flipped the formula in iteration 2.

  • @harish10a91a0591
    @harish10a91a0591 7 лет назад +1

    This video is really helpful.. I want to add a point here. When we are iterating v-1 times, can we break off in the middle when there is no update in the distance map (in a specific iteration just like best case of bubble sort)? I think without a single update we iterate through the same values and won't get a better distance until the end. Correct me if m wrong

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

      u r correct, u can store changed vertices in a queue..

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

    Excellent work Sir :)

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

    very well explained. Thank you :)

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

    Awesome !! can you please post Floyd Warshall too... Thanks in advance

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

      +Tushar Roy Thank you so much :)

  • @DeepikaSingh-io3ou
    @DeepikaSingh-io3ou 8 лет назад

    thnks sir... excellent explanation.. keep it up

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

    How u have time to make these nice videos?..... @Apple developer :) Hats Off to ur Work...

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

    It's a good explanation. However, I've one question: in the code when you do : `distance.get(u) + edge.getWeight()`, there can be integer overflow because `distance.get(u)` could return `INFINITY`. How does Java handle this? Also, there could be integer overflow even if `distance.get(u)` does not return `INFINITY`.. it is because `x + y`, in general, could overflow!

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

    Thanks for the vedio Tushar. Really appreciate your effort. Could I ask for a link to the graph Class you create. Just need for my reference.

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

    Thank u sir........🙏🙏

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

    @Tushar Can you please explain why Dijkstra's algorithm does not work if there are negative weight edges?

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

    Thank you. it was awesome :)

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

    nice vedio .worth watching.👍

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

    very helpful, thank you

  • @shyamtripathy5084
    @shyamtripathy5084 8 лет назад +5

    Thanks for your videos. I literally watched all your videos. Awesome work. I think, u can reach out to GeeksforGeeks and ask to link your videos there.
    Or, how about having your own website with all these videos. :) :)

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

      so on average we are taking v-1 times for relaxing edges from source.So why can't i processes those edges from source itself.It will take |E| time complexity only??

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

    Thank you

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

    it was confusing at the beginning but I got it.

  • @albundy2765
    @albundy2765 7 лет назад +4

    Tushar that is a great flannel. I am concerned about the coffee stain near the left breast panel however. Please let me know if you were able to get it out with the washing machine. Anxiously awaiting your response.
    Also thank you for this video.

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

      _--. He is teaching gold and you only care about a coffee stain? --_

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

    Thankyou so much sir :)
    Could you please upload a video on the application of bellman-ford i.e., linear programming problem by difference constraints

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

      so on average we are taking v-1 times for relaxing edges from source.So why can't i processes those edges from source itself.It will take |E| time complexity only??

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

    take edges in this order..... this prblm will be solved in on step
    0 >1=4
    0>2=5
    1>2=-3
    2>4=4
    0>3=8
    3>4=2
    4>3=1

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

    Thank you so much

  • @tlshruti1379
    @tlshruti1379 7 лет назад +4

    Lectures explained well but sir,s pronouncation is distarcting

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

    What if we take edges 0-2 and 0-1 before everyone else... you are bypassing the fact by considering those edges first whose both vertices are infinity. If 0-2 and 0-1 are taken first then in 1st iteration only other vertices are relaxed but it shouldn't be as shown in the textbook. Still confused how it's happening.

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

    Thank you ❤️

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

    so on average we are taking v-1 times for relaxing edges from source.So why can't i processes those edges from source itself.It will take |E| time complexity only??

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

    This guy is fucking amazing

  • @md.sayeedrahman2553
    @md.sayeedrahman2553 4 года назад

    Heyyy, what if the graph contains a cycle of postive weights??

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

    sir initial of the video u have 5 vertices and later 4 vertices

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

    great!

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

    hi tushar roy. i just want to know whats the difference between these three algorithms: Bellman-Ford, Dijkstra, and Floyd-Warshall algorithms. Which algorithm is more accurate to solve the shortest path?

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

      thank you Tushar :). but do you think that its better to use the Floyd Warshall Algorithm? since it detects the shortest path from every other node??

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

      aries cruz Bellman and Floyd use dynamic programming whereas Dijkstra uses greedy strategy. The Bellman-Ford and Dijkstra's algorithm output a shortest path from an input vertex r to all other vertices reachable from r, whereas Floyd's algorithm generate shortest path between all pairs of vertices of the digraph. Also, Dijkstra works with weighted digraph with non negative edges. Bellman Ford works with digraphs with no negative cycles. Next you can talk about their differences on the basis of difference in time complexities.

  • @MeganLee-Dror
    @MeganLee-Dror 4 года назад

    Why we need to do V-1 rounds: 13:05

  • @fazithfouseen1548
    @fazithfouseen1548 7 лет назад +1

    please upload Single Source Longest Path Graph Algorithm......!

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

    Can you upload same problem with the link failure?

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

    How to find the longest path with the same algorithm ?

  • @aprofromuk
    @aprofromuk 7 лет назад +2

    tussi gr8 ho :)

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

    he is from nit allahabad and works at apple

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

    I owe you my degree

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

    how can a distance between 2 vertices be a negative number?

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

      Weights are not always distances but are cost to reach that vertex which can we negative in some cases.

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

      cost being negative, so this is better than free. i lack in understanding of real world application when this is the case.

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

    wanna know why v-1 times? go to 12:59

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

    it is weird how you pronounce V . Video= WE-deo. Vertices = WE-rtices xD

    • @aprofromuk
      @aprofromuk 7 лет назад +1

      its not his mother tongue unlike yours :)

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

      Tufayel Talha and two is thooo.. lol

  • @Herotruth
    @Herotruth 8 лет назад +1

    V

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

    he looks like sandeep maheshwari :|

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

    Youre really rushing ahead with the concept without giving a clear explanation about the working of the algo .. same goes for your other videos

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

      initialize with INT_MIN,INT_MIN,INT_MIN......
      for each edge u,v,do:
      if(dist[v]v)
      dist[v]=dist[u]+weight(u->v).

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

    In below commentof mine "vV1" is "V-1"

  • @deb8810
    @deb8810 7 лет назад +2

    You have done a good video on this topic . but brother dont try to pretend as american . coz its sounding pretty bad ..

  • @himadrianjoy9782
    @himadrianjoy9782 7 лет назад +4

    hello tushar , your word pronunciation is really bad , so can you please make your voice dry and use correct indian pronunciation

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

    Slowly please Sir slowly..why so doing quickly !!

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

    Hindi ma phara lai

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

    I can't pay attention to the lecture because of that stain on your shirt.

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

      oh good, you turned around.

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

    Tushar, bro you aren't a teaching material ! Go find some other job ! Don't waste your time.