Dijkstra's algorithm in 3 minutes

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ส.ค. 2024
  • Step by step instructions showing how to run Dijkstra's algorithm on a graph.
    Code: github.com/msa... (different than video, I added this retroactively)
    Source: Algorithms by S. Dasgupta, C. H. Papadimitriou, and U. V. Vazirani [www.amazon.com...]
    LinkedIn: / michael-sambol

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

  • @rahulsonwalkar3663
    @rahulsonwalkar3663 7 ปีที่แล้ว +3965

    When you had an entire semester to study but you delay it till the last hour.

    • @ObradovacPower
      @ObradovacPower 6 ปีที่แล้ว +45

      SO TRUE HAHAHA!!!!! lmao

    • @BiancaDianaT
      @BiancaDianaT 6 ปีที่แล้ว +17

      On point ._.

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

      气死我了,被抓包了

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

      30 min*

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

      So damn true, my exam is in twenty minutes lol.

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

    I just learned more in that 3 minutes than the last 2 weeks of my programming class. Thanks a lot! :)

  • @ThisClark
    @ThisClark 9 ปีที่แล้ว +495

    mikey, keep it up. you're cutting the other videos down by minutes - it's super efficient to study with you

    • @MichaelSambol
      @MichaelSambol  9 ปีที่แล้ว +58

      James Clark Thanks, James. More coming soon.

    • @psibarpsi
      @psibarpsi 8 หลายเดือนก่อน +3

      An implication of Parkinson's Law.

  • @Tombalino
    @Tombalino 8 ปีที่แล้ว +122

    Finally a clear, short and simple explanation :)
    On behalf of everyone, thankyou and good job

  • @sumitsapkota3792
    @sumitsapkota3792 7 ปีที่แล้ว +428

    What my teacher teach for whole semester I can learn over a night on TH-cam. Why the hell I am paying my semester fee, Instead I should pay for high speed broadband.

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

      what kinda teacher teaches dijkstra's algorithm for a whole semester?

    • @ramimxss
      @ramimxss 4 ปีที่แล้ว +15

      @@ROFEL he meant everything his University or college covered in a semester,he is right though, sometimes

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

      @@ramimxss s

    • @loot6
      @loot6 3 ปีที่แล้ว +12

      There isn't anything you can't learn faster and more easily at home with the internet - all you need is motivation.

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

      ​@@loot6 so true

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

    It's crazy the fact that a 3 min video teaches me way better than a 1 hour class video of my teacher. Why do teachers always struggle with teaching in a simple way?

    • @BossKing1243
      @BossKing1243 ปีที่แล้ว +29

      A lot of them become teachers bc they’re really intelligent and hardworking, not because they’re actually good at teaching

    • @Omenemperor2
      @Omenemperor2 10 หลายเดือนก่อน +7

      @@BossKing1243 Can't agree more, most of them are good at doing research rather than teaching us

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

      @@BossKing1243 Yup exactly.

    • @adriangjonca680
      @adriangjonca680 2 หลายเดือนก่อน

      Also classes move at the pace of the slowest learner. While videos go at superspeed, knowing you can just rewind a section you don't understand.

  • @iizvullok
    @iizvullok 7 ปีที่แล้ว +139

    You just needed 7 minutes (actually less) to explain everything I did not understand in more than 3 hours! Thank you!

    • @AB-ld1rp
      @AB-ld1rp 7 ปีที่แล้ว +4

      Excuse me for using your top comment, but I have to let people see this: Sorry, but this algorithm is incomplete and not capable of solving a problem that my professor gave me. It works for the simplest matrices, but that's that. As a proof try to solve this exercise as said in the video:
      find the shortest route from f to c. The matrix is:
      . a b c d e f
      a 0 2 4 0 0 5
      b 9 0 0 7 5 0
      c 4 3 0 8 0 0
      d 0 3 9 0 0 6
      e 6 0 0 5 0 0
      f 0 5 0 6 3 0
      The solution should be 13 (f-e-a-c) but with this algorithm you will never obtain it.

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

      worked for me

    • @VandamePlays
      @VandamePlays 6 ปีที่แล้ว +21

      There is an error in this explanation, I actually learnt the base of the algorithm here since the explanation is very simple and I came to find that it wasn't completely right. The error is when he says that we choose the edge with the minimal cost in order to visit a certain node, that's not the case, we have a list of the unvisited nodes and from all those nodes, the algorithm says that the next node to be visited is the node with minimal TOTAL distance to the origin, remember every visited node tries to update the adjacents nodes.
      You wrote this a long time ago, but I hope new viewers don't fall for the same mistake I did when I only based in this explanation.

    • @Khaleb_0
      @Khaleb_0 6 ปีที่แล้ว +4

      but if that's the case where's his mistake? he always chooses the "cheaper" one realtive to the origin? or are you saying that his wording was poor?

    • @OrnateOwl
      @OrnateOwl 6 ปีที่แล้ว +3

      I believe he's talking about the wording. The lack of explanation about how he did what he did for the sake of simplicity.

  • @fitwithrmj
    @fitwithrmj 7 ปีที่แล้ว +143

    bro u save me just 13 hrs before my exam...

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

      13 hours is a lot of time dude

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

      nice now 3 years later i got an exam tomorrow. Hope i do really well.

    • @adamplayz-qf8ry
      @adamplayz-qf8ry 4 ปีที่แล้ว +2

      Broo....

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

      13 hrs. You're like a baby. Watch this
      S I X H O U R S

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

      Nice

  • @rayryeng
    @rayryeng 3 ปีที่แล้ว +9

    Someone who can actually take on Siraj Rival's mantra of learning something in 3 minutes lol. Very well explained, especially for someone who has seen this before but needed a quick refresher. Thanks so much!

  • @JonathanRose24
    @JonathanRose24 6 ปีที่แล้ว +16

    Getting ready for an interview and this is EXACTLY what I needed. THANK YOU!

  • @z.m.4331
    @z.m.4331 7 ปีที่แล้ว +8

    You're exactly the type of human the internet needs! Thank you!! :D

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

    I've been almost a month learning it and still don't understand what it is. Now you can make me understand in 3 minutes. I love you and thank you. God bless you!!

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

    I've been watching hours of lecture videos talking about these and haven't understood them until your 2-3 minute videos! Thanks! Much less stressed now.

  • @antonhall2696
    @antonhall2696 9 ปีที่แล้ว +35

    This is great! Short, simple and very easy to follow. I like that you've made the pictures beforehand and don't draw freely during the video.
    Liked and subscribed :)

  • @farzaadify
    @farzaadify 9 ปีที่แล้ว +18

    This is like a quick revision during exams,Thank you .

    • @ethandenson7182
      @ethandenson7182 6 ปีที่แล้ว

      do you mean review?

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

      why tf do you have access to TH-cam during exam

  • @kevinqagish2287
    @kevinqagish2287 8 หลายเดือนก่อน +3

    Alter Geile Meile ich bin die Ganze Zeit am versuchen die Funktion Anhand meiner Vorlesungsmaterialen zu verstehen und komm 0% vorwärts ... Ich gehe auf TH-cam schaue mir ein 3 Minuten Video and und verstehe es direkt! Vielen Dank!! Das Video is sau stark !!!

    • @MichaelSambol
      @MichaelSambol  8 หลายเดือนก่อน +2

      Danke fürs zuschauen!

  • @easyas-is
    @easyas-is 7 หลายเดือนก่อน +1

    2024 here and you are a genius for explaining the algo so clear

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

    bro for the last two years I come back to this video every once in a while because I need it for a different class.. Thanks, you're awesome :D

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

    I showed up an hour late to class and missed the explanation for this. This 3 minute video explained everything I needed to know thank you!

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

    This is actually legend. I searched up many long videos explaining it but only this short one helped me understand

  • @MidnightBloomDev
    @MidnightBloomDev 4 ปีที่แล้ว +18

    When you have 30 minutes before final semester exam but you didn't study at all

    • @adriangjonca680
      @adriangjonca680 2 หลายเดือนก่อน

      LMAO I'm here the day before my ALevel CS exam.

  • @MyNguyen-ln1dv
    @MyNguyen-ln1dv 7 ปีที่แล้ว +2

    You seriously need to make more videos about algorithm. They help me sooooo much. Thanks a lot

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

    These 2 min reviews are a god send! Final in 3 hours...

  • @d_asude
    @d_asude 2 หลายเดือนก่อน +1

    Thanks to you, I finished 4 different topics 1 hour before the exam 😀

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

    Dude, I love you

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

    I like how those videos are 2-3 minutes but it always take me 15+ minutes to watch them to the end

  • @livea404life
    @livea404life 2 หลายเดือนก่อน

    Thx! You helped me passing algorithm course exam last year, and I believe this video can help me passing the network course exam again!

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

    Short and sweet. We need more videos like this.

  • @Kaira_edits8
    @Kaira_edits8 2 หลายเดือนก่อน

    I felt so stressed for the exam coming in three days, and now I found your channel explaining everything so simply, thank you ❤

    • @MichaelSambol
      @MichaelSambol  2 หลายเดือนก่อน +1

      welcome! crush it

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

    most Teachers in Uni are so focused on proving the algorithm works, and is the best way to do 'X' - to the point they dont notice, or care, if the students even understood what the algorithm does or even supposed to do.
    thank you

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

    Even 8 years later you're still saving lives with this

  • @ogCharaLM
    @ogCharaLM 8 ปีที่แล้ว

    Thank you for this. There aren't enough truly concise videos out there, and I was getting desperate.

  • @thanasulas08111994
    @thanasulas08111994 10 ปีที่แล้ว +28

    Simple and well explained. Thank you very much!
    It would be really great if you could make a video for Bellman-Ford algorithm too.

    • @MichaelSambol
      @MichaelSambol  9 ปีที่แล้ว +8

      thanasulas08111994 ***** Working on it now!

    • @MichaelSambol
      @MichaelSambol  9 ปีที่แล้ว +28

      th-cam.com/video/obWXjtg0L64/w-d-xo.html

  • @davidwong666
    @davidwong666 4 หลายเดือนก่อน

    Gonna have my final exam in 15 mins and I am here reivising the last topic taught in the lecture. Thanks!

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

    EVERYONE explains this so hard this REALLY helped me thank you

  • @mr.paarthurnax2649
    @mr.paarthurnax2649 3 ปีที่แล้ว +2

    This explanation was awesome! So simple and concise. Thanks!

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

    your videos are the best. Nobody wants to watch a 20 minute video just to pass their exam

  • @li-pingho1441
    @li-pingho1441 3 ปีที่แล้ว +1

    The best tutorial ever

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

    Incredible video. Thank you you hero. So many videos of 20 minutes + that cannot get to the point.

  • @audiomac
    @audiomac 9 หลายเดือนก่อน

    My textbook never told me what "cost" was. It randomly started using that term. Thanks!

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

    best videos ever .... to understand data structure in few minutes ..
    make more videos
    ..plz

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

    Thanks a whole lot. However, from 1:41 why do we use the weight 3 instead of weight 1? That is the only thing I do not seem to understand. Thank you in anticipation of your response.

    • @w花b
      @w花b 9 หลายเดือนก่อน

      I don't understand what you're asking but one thing to keep in mind for others that might see your comment is that we add the value of the node you're in to the value of the node you want to go to and compare that result to the current value in your node list for the one you want to reach. If it's infinity then you place it but if it's equal or smaller than your sum then don't change it.

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

    This psuedocode rendition is nice, compact, and readable. Much better than a lot of the other ones you see.

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

    i hope this comes clutch for me learning it from scratch for a semester exam tomorrow.

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

    Thank you! I fell asleep during my lecture, this was a lifesaver!!

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

      Happens to the best of us 😴

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

    It was the most useful 3 minutes in my life . Thank you.

  • @tangdexian3323
    @tangdexian3323 6 ปีที่แล้ว

    I really like your approach, concise and to the point

  • @skelswap
    @skelswap 4 หลายเดือนก่อน

    had to catch up after not going to a lecture, but i cant imagine how tf it took an entire lecture to explain this and one other algorithm

  • @Bred0nSch00lV2
    @Bred0nSch00lV2 5 ปีที่แล้ว

    A nice condensed little video. Thank you.

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

    I have nothing against indian guys, they are smart and great people... But listening to an American English speaker is a pleasure to my ears.

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

    Watched it for an interview, when I went for the like button, I noticed that I already liked it, probably from my BSc years. I never learn 😂😂😂

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

      Welcome back, and thank you for watching! Good luck on your interview.

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

    an algorithm my professor took 3 classes to explain and this dude didnt even need 3 minutes.

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

    you're an angel

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

    Great video! Thank you so much for making it.

  • @jordancleeve7548
    @jordancleeve7548 8 ปีที่แล้ว +4

    Awesome video thanks!

  • @ManhTran-ry9ux
    @ManhTran-ry9ux 4 ปีที่แล้ว

    OMG, finally all my semester can wrap up by approximately 3 minutes =)))

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

    Thanks, Michael this video's very helpful.

  • @lalwho
    @lalwho 8 ปีที่แล้ว

    cool video series for a quick recap before the exams...

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

    Exam in 1 hour, thanks for this!

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

    my prof recommended me to watch this instead him teaching. not because he lazy but this explaination is just good

  • @theamici
    @theamici 6 ปีที่แล้ว +32

    U need to keep track of the paths and not just the values leading up to the nodes. Dijkstra's algorithm gives you a path with a value, not just a value.

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

      That's already been done in the video. You can obtain the shortest paths to each node by tracing the values in the "prev" Array/HashMap (shown in the pseudo code at the end).

  • @yusram.6175
    @yusram.6175 8 หลายเดือนก่อน +2

    I'm confused @1:33 why did D and E change to one less than what they were before?

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

    Concise and straight to the point. Thanks =)

  • @HuyPham-id7us
    @HuyPham-id7us ปีที่แล้ว

    thank to your video! That video is better than my professor's lecture

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

      You're welcome, Huy! Thanks for watching.

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

    I can't believe I just found the Holy Grail of TH-cam channel for CS students

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

    thank you so much for this! Life changing

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

    you deserve a plenty of likes dude. i like how you shorten the video for us ❤️

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

    Very clear explanation. Thank you!

  • @andywei5518
    @andywei5518 5 ปีที่แล้ว

    unsw trimester is very busy, but thanks, you saved me a lot of time ~ ! ! !

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

    michael you beautiful man you've saved me from an awful grade

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

      Guess who's nearing the awful grade now :)

  • @gedeonandrasmusic
    @gedeonandrasmusic 6 ปีที่แล้ว

    Very great, thanks for your help!

  • @sarveshpandey1125
    @sarveshpandey1125 6 ปีที่แล้ว

    It's such a perfect explanation.

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

    You are such a king

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

    Thank you soomuch yaar you made my day much better

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

    My g saving people life right now

  • @nemanjabosko
    @nemanjabosko 11 หลายเดือนก่อน

    I passed algoritm class because this man

  • @Shkencetari
    @Shkencetari 6 ปีที่แล้ว

    Great tutorial. Thank you very much.

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

    my man thanks for saving me time

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

    i wasnt sure wgat the differnce between this and bfs is. thank you so much!! 💅

  • @semoreyad2933
    @semoreyad2933 6 ปีที่แล้ว

    good , simple and clear explanation , thank you :D

  • @kp7jim
    @kp7jim 6 หลายเดือนก่อน

    This vid is the way I'm passing my Computer Networks class tmr

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

    Exam saver!! Thanks

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

    Your videos are great!

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

    thank you dude for saving my life :D

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

    Bro u truly are the best keep up 🔥

  • @digvijayandhorikar936
    @digvijayandhorikar936 8 ปีที่แล้ว

    GOod..fantastic.It was like the fastest way..PErfect man keep it up!!!!!!

  • @davidboublil
    @davidboublil 8 ปีที่แล้ว

    thank you so much!!! You saved my life (again)

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

    This is so good. Thanks!

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

    thank you, straight to the point,

  • @ognjensimic5042
    @ognjensimic5042 6 หลายเดือนก่อน

    Hvala brate moj!

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

    I have my exam in 30 minutes this is perfect

  • @jimkash7133
    @jimkash7133 6 ปีที่แล้ว

    a truly inspired work 10/10

  • @ChaoZonic
    @ChaoZonic 8 ปีที่แล้ว

    Thanks for the excellent video: I now know how to pronounce Dijkstra!

  • @learnfullstackqaonline
    @learnfullstackqaonline 8 ปีที่แล้ว

    thanks! this really helped me a lot!

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

    Very helpful!

  • @MYY-on5rk
    @MYY-on5rk 4 หลายเดือนก่อน +1

    I believe there might be an error in your results at 2:09. Shouldn't the path sequence be A -> C -> B -> E -> D, instead of both B -> E and B -> D? Following the A -> C -> B -> E -> D route results in a total cost of 7, rather than the cost of 8 that was concluded. Could you please verify this?

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

      exactly my thought

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

    Thanks, good Tutorial

  • @Daniel-iy1ed
    @Daniel-iy1ed ปีที่แล้ว

    You are amazing man 🤩🤩

  • @josemunguia5660
    @josemunguia5660 6 ปีที่แล้ว

    Great video! Thanks!

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

    Sir...thank you very much!