No video

Kruskal's algorithm in 2 minutes

Step by step instructions showing how to run Kruskal'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

Пікірлер: 425

  • @AnishKaranPhotography
    @AnishKaranPhotography8 жыл бұрын

    Are you from outer space? My lecturer couldn't explain this in 2 hours and you did in 2 mins. Thanks a lot.

  • @peterbakke

    @peterbakke

    6 жыл бұрын

    Math and CS educators need to work backward from this video. Have the students obtain an intuitive understanding of what's going on, and then drone on for 2 hours. Hopefully, something sticks. Way to go, Michael!

  • @diwang4572

    @diwang4572

    3 жыл бұрын

    @@Fedorahatter exactly, my professor talked about bunch of lemma and proofs first and then go on briefly touched upon the algorithm which we were all lost by the time he talked about it which was like 1 hour into the lecture.

  • @mavyfaby

    @mavyfaby

    2 жыл бұрын

    Same, this video is much better than my lecturer explaining this topic in an hour still I didn't understand. I wish he'll explain like this.

  • @adelalmohtaseb5261

    @adelalmohtaseb5261

    Жыл бұрын

    Fr me as well.

  • @danielriley3618

    @danielriley3618

    Жыл бұрын

    😆

  • @Elmirgtr
    @Elmirgtr9 жыл бұрын

    you explained something in 2 minutes what my prof did in two lessons.

  • @MichaelSambol

    @MichaelSambol

    9 жыл бұрын

    Elmir Ma Glad I could help!

  • @Griff10poldi

    @Griff10poldi

    8 жыл бұрын

    +Elmir Ma Same thing here.. I've wasted my time at class lol

  • @Elmirgtr

    @Elmirgtr

    8 жыл бұрын

    Griffin Seannery and I ended up doing well in that class. Thanks again, uploader!

  • @school_pizza

    @school_pizza

    4 жыл бұрын

    @@Elmirgtr Some stories have fairy tale endings.

  • @Elmirgtr

    @Elmirgtr

    4 жыл бұрын

    @@school_pizza So true. When I wrote this I was in undergrad, now I am doing PhD and working on a paper to submit to Nature

  • @mohammedabdulrafay
    @mohammedabdulrafay5 жыл бұрын

    “If you can't explain it to a six year old, you don't understand it yourself.”

  • @xbit97
    @xbit973 жыл бұрын

    It's incredible how my teacher's lessons started talking about cycles and cuts and shit formulas while the algorithm is so freaking simple... Order edges by weight, go through them in that order, if the edge connects different trees use it, if it connects the same tree discard it, was that so difficult? Thank you for this clear explanation dude, you rock

  • @miguelflor1600

    @miguelflor1600

    Жыл бұрын

    ele deu gosto porque é bueda da fixe

  • @R1CARD049
    @R1CARD0498 жыл бұрын

    Thank you so much, we were given incomprehensible pseudo-code and confusing notation. For this to seem so simple after a

  • @MichaelSambol

    @MichaelSambol

    8 жыл бұрын

    +Richard Paul You're welcome, Richard. Glad you enjoyed.

  • @08a14979

    @08a14979

    6 жыл бұрын

    i hate discrete math with passion. making something simple look so complicated

  • @biblemansings

    @biblemansings

    Жыл бұрын

    @@08a14979 lmao im genuinely worried im going to fail discrete math. I swear it’s how my professor teaches. He overcomplicates everything and he will talk about one thing for like an hour so it’s too easy to get confused.

  • @wade3ed
    @wade3ed3 жыл бұрын

    tfw: this is actually really simple but your professor unnecessarily complicated it

  • @w4439
    @w44396 жыл бұрын

    Your tutorials are the best! I learned 2 months of discrete mathematics in under 30 minutes. 5 years have passed since you posted this but it has had a larger impact on my understanding than my professor has provided all semester. Thanks.

  • @marflage
    @marflage4 жыл бұрын

    For those who are a bit confused, he did not search for 7 by skipping 4, 5, 6. He did in fact search for them but found them to be making a circuit (closed path with previously chosen nodes).

  • @brettsharpe7305

    @brettsharpe7305

    7 ай бұрын

    You just said he didn’t

  • @JJCUBER

    @JJCUBER

    4 күн бұрын

    @@brettsharpe7305the second part where they say that they did search refers to the rest of the numbers. In sum, all edges were considered in increasing order, but the ones which would create a cycle were discarded.

  • @MisterTipp
    @MisterTipp8 жыл бұрын

    Fucking legend mate!

  • @darthrevan204
    @darthrevan2047 жыл бұрын

    4 hours of discrete mathematics lectures and seminaries ... compressed in 2 minutes. you sir, are a life saver

  • @gongjiaji2489
    @gongjiaji24897 жыл бұрын

    you are my time saver, I spend many hours on PPT, blog and other videos, none of them explain so clearly in this manner. they try to be professional so that they don't speak nature language. Thank you very much.

  • @saeedbaig4249
    @saeedbaig42496 жыл бұрын

    0:56 - "Notice the smallest edge is BE, but this node connects 2 nodes that are already in the same tree, so it will not be chosen." I think you could have picked your words better. The reason we don't choose BE is NOT because B and E are already in the same tree (I mean, so were A and C, yet you added AC), but because adding BE would create a cycle in the tree, and MSTs aren't supposed to have cycles.

  • @kirandhakal8601

    @kirandhakal8601

    4 ай бұрын

    You cleared my confusion. Thank you.

  • @keagenmccartha7412

    @keagenmccartha7412

    3 ай бұрын

    how is that confusing? if both points are already discovered then u arent adding a new point to the tree... its just a wasted edge

  • @squeesquee6

    @squeesquee6

    3 ай бұрын

    @@keagenmccartha7412because he did that with AC even though both were already in the tree. Just because you are r€t@rded doesnt mean you need to yap about it to everyone else.

  • @anirudhkrishna.s5397

    @anirudhkrishna.s5397

    2 ай бұрын

    @@keagenmccartha7412 because "A spanning tree of a graph consists of all nodes of the graph and some of the edges of the graph so that there is a path between any two nodes"

  • @keagenmccartha7412

    @keagenmccartha7412

    2 ай бұрын

    @@anirudhkrishna.s5397 congrats genius

  • @har0111890011
    @har01118900112 жыл бұрын

    Absolute Chad ; Saving me from my algorithms exam tomorrow. My Lecturer took so much explaining these concepts but you are a genius made it easy in no time. Cheers !

  • @geekinthehattech
    @geekinthehattech10 жыл бұрын

    Very nice video. Straight to the point and quick.

  • @emilyhuynh7855
    @emilyhuynh78558 жыл бұрын

    You're a lifesaver! Got an exam tomorrow and my textbook nor my professor was making sense to me. Glad to know it was a much easier process than I initially thought!

  • @Dorddis

    @Dorddis

    Жыл бұрын

    he's saving lives still... been 6 years!

  • @felixcuello
    @felixcuello4 жыл бұрын

    I wondder WHY at university they spend 20-30 minutes explaining this, and having round of questions. Your 2 minute videos explaining algorithms are simply PERFECT. Thank you very much indeed.

  • @KillerKillcam
    @KillerKillcam9 жыл бұрын

    because of your videos, I learned Kruskal's and Prim's algorithms in 4 minutes. My teacher took 10 minutes to do an example of Prim's and I didn't even understand it then. thanks!

  • @Khadari2013
    @Khadari20134 жыл бұрын

    what amazes me is how I seat through 2 hour of lecture class and couldn't understand a jack thing but 2 minute video and I feel like replacing my professor so I can teach the class.

  • @mariestolk3794

    @mariestolk3794

    4 жыл бұрын

    Same

  • @rrestoring_faith

    @rrestoring_faith

    4 жыл бұрын

    I would still suggest staying in lectures. For instance, this videos states that you can use merge sort to sort the Edges. Which is fine and true, but why would you even bother? Why use merge? Why not a priority queue? He also doesn't explain the time complexity. You can perform Kruskal's in O(ElogV) but his is O(ElogE) because merge sort is dominating. Which is better? [Most examples show E >= V]. These videos are great for getting the point and quickly understanding how it works, but when you get into it the details may not be as good as you'd think.

  • @theendurance

    @theendurance

    4 жыл бұрын

    @Rrestoring faith Exactly. This video doesnt actually teach you anything. It simply shows what Kruskal's aglorithm is. This is way too basic to be useful

  • @pchanio
    @pchanio3 жыл бұрын

    I just love that you simply get to the point.

  • @MichaelSambol

    @MichaelSambol

    3 жыл бұрын

    Thank you!

  • @miguelflor1600

    @miguelflor1600

    Жыл бұрын

    @@MichaelSambol és bueda da fixe

  • @mitchell2719
    @mitchell27198 жыл бұрын

    This was way easier than my prof's explanation. Thank you so much!

  • @RigorousExplorer
    @RigorousExplorer2 ай бұрын

    Dude I spent a whole lecture not understanding and it's actually this straight forward

  • @user-hl2pr4qg8e
    @user-hl2pr4qg8e2 ай бұрын

    The explanation is very intuitive and concise, thank you so much.

  • @mrndc
    @mrndc8 ай бұрын

    From what I've learned: If you are stuck between choosing multiple edges with the same weight, like in 0:40, (A, D) or (A, C), or (B, E) Choose the one that doesn't create a cycle, if none of them create a cycle: Prioritize the edge that is alphabetically first. In this case, (A, C) is the first in the alphabetical order.

  • @Sonikkid1
    @Sonikkid13 жыл бұрын

    Even in 2021, you are still relevant. Thank you for your service

  • @asdf9481234
    @asdf94812345 жыл бұрын

    you're making those kind of how to-videos everyone is looking for, a good explanation with no annoying blabla, thank you!

  • @shorty235z
    @shorty235z6 жыл бұрын

    My professor took over an hour trying to explain Kruskal's algorithm. You did it in less than 2 minutes. Someone tell NASA to hire this fucking man!

  • @salihbalkan5083
    @salihbalkan50838 жыл бұрын

    Perfect tutorial I have ever seen. Thanks, I got it in just 2 minutes!

  • @Zeldarulah
    @Zeldarulah10 жыл бұрын

    Seems simple enough.. but not so simple for coding :P

  • @MidnightBloomDev

    @MidnightBloomDev

    4 жыл бұрын

    You could do this with 10 lines of python code

  • @vtvtify

    @vtvtify

    4 жыл бұрын

    @@MidnightBloomDev Ummmm, despie it indeed being simple to code, just the union find used is not 10 lines...

  • @isakjacobsson867

    @isakjacobsson867

    3 жыл бұрын

    This is a one liner ez

  • @Hgh38

    @Hgh38

    2 жыл бұрын

    Nah once you implement these things, it gets easier. I lowkey love to do it.

  • @rrrushan
    @rrrushan3 жыл бұрын

    Still relevant in 2021. Thank you!

  • @miguelflor1600

    @miguelflor1600

    Жыл бұрын

    ele deu gosto porque é bueda da fixe

  • @Arthur-Joe
    @Arthur-Joe7 жыл бұрын

    Thanks - this was concise and helpful. It cleared up my confusion of whether the tree must be connected from the beginning or not.

  • @mrbloke491
    @mrbloke4917 жыл бұрын

    my god man you are amazing, you just explain it without taking 10 years THANK YOU

  • @AwsomeAlligator
    @AwsomeAlligator7 жыл бұрын

    It would be cool if you added a short video about union and find as an addition to this video, as the intuition for Kruskal's algorithm is explained brilliantly here, but the implementation needs to use union and find for the complexity to be as good as you mention and these functions are quite interesting and not completely trivial. Thanks for all your great videos btw, they are very clear and concise :)

  • @me-zb7qm
    @me-zb7qm7 жыл бұрын

    Thank you so much for this, my professor didn't even explain a thing but included this in the midterm I'm having in 13 hours. You're a lifesaver.

  • @capelo2148
    @capelo21489 ай бұрын

    You are a LIFE SAVIOR. Thanks!

  • @alexeukleidis1611
    @alexeukleidis16119 жыл бұрын

    Sir you are the Best!!!!!!! The shortest and meaningful video that can be created!!!! Thank you SO much!!!!

  • @JamesBrodski
    @JamesBrodski Жыл бұрын

    Great video. Thanks so much for making it!

  • @JoonJulyAugust
    @JoonJulyAugust9 ай бұрын

    Ran across this video again during my university algorithm course studies. Thank again Mike!

  • @MichaelSambol

    @MichaelSambol

    9 ай бұрын

    Boom! Awesome. 💪🏼❤️

  • @stefanchelbosu1
    @stefanchelbosu16 жыл бұрын

    I hate when my university professors start by explaining abstract shit and formulas and general cases, u fall asleep, and in the and they say aaalll this just to remove all possible edges. I mean they could start with catching your attention with an example, and then expand on the subject for 3 hours. It would be so much better.

  • @Abdullah-cm1tn

    @Abdullah-cm1tn

    3 жыл бұрын

    yes, they don't start with examples. they start with abstract formulas and equations, confusing the hell out of us. then give the most complicated example they can find from the book. pathetic.

  • @brendawilliams8062

    @brendawilliams8062

    Жыл бұрын

    You cannot cycle it and it’s information can only go through a process of its this than it’s that.

  • @Unknownsoldier740
    @Unknownsoldier7407 жыл бұрын

    Fast, clean, and with a good example. Quality work, you did good. Thank you.

  • @polkadotorchidea404
    @polkadotorchidea4049 жыл бұрын

    Thanks a lot! I have a test tomorrow xx

  • @MichaelSambol

    @MichaelSambol

    9 жыл бұрын

    Polka dot Orchidea Glad I could help!

  • @miguelflor1600

    @miguelflor1600

    Жыл бұрын

    @@MichaelSambol és bueda da fixe

  • @madeleine6472
    @madeleine64729 жыл бұрын

    Really saved my day after spending hours in the text books to understand this. Thanks a lot!

  • @Xtremedave2
    @Xtremedave28 жыл бұрын

    Ohhh I never knew that the arcs should only add new nodes, I was only taught that it should not create cycles. This makes it a lot easier. Great vid mate

  • @drewkelly3622
    @drewkelly36228 ай бұрын

    my professor made this WAY more confusing in a 75 min lecture, you explained it perfectly in 2 minutes

  • @ankitb3954
    @ankitb3954 Жыл бұрын

    I watched this during my bachelors, now I am watching it during my masters hopefully will be back during PhD

  • @MichaelSambol

    @MichaelSambol

    Жыл бұрын

    go get that doctorate

  • @SaminaAKhan-ck1oj
    @SaminaAKhan-ck1oj8 жыл бұрын

    You are awesome. Seriously you taught a whole book chapter in just two minutes. 👍🏻

  • @Elliott_Ives
    @Elliott_Ives4 жыл бұрын

    Michael, your vids are so succinct and effective.

  • @OdiyaS
    @OdiyaS8 жыл бұрын

    Thanks!!! You literally saved me ... and my exam's tomorrow! You explained something in 2 minutes when in class it took like 2 hours!

  • @anything413
    @anything4139 жыл бұрын

    Great stuff man,,, crisp and precise... never going to forget Kruskal's algo now

  • @indieelectroworks
    @indieelectroworks7 жыл бұрын

    Your material is simply excellent! I can't wait for more!

  • @thomaschurch1969
    @thomaschurch19693 ай бұрын

    Very succinct and to the point. Thanks for this.

  • @gunjansethi2896
    @gunjansethi28968 жыл бұрын

    Saved my life on the exam morning! Thank you so much :D

  • @Derbb
    @Derbb2 жыл бұрын

    I never watched anything on this nor was taught in class so I’m just looking at this out of own interest, but that seems extremely easy. Can sort the edges, then take the minimum such that there is no cycle made. Cycle can easily be found, if you use a set for nodes that are connected to the MST being built, if both have been visited, then you don’t consider that one at all, skip. Alternatively for those into competitive programming, a min segment tree could be an interesting use case. O(e) to build, o(log e) for queries on min and updating edges you add in to be an int max length. Then again you’d have e queries at most, and each query/update takes log e time, so still e log e, but just preference and a different way to look at it.

  • @aidenzhang5959
    @aidenzhang59597 жыл бұрын

    My professor explained this for 20 minutes and couldn't make the idea clear. Thank you.

  • @dlim9696
    @dlim96966 жыл бұрын

    Hi I have a final exam CS 1332 tomorrow morning and your video helped me a lot. Thanks so much and go Yellow Jackets!

  • @ausreir
    @ausreir4 жыл бұрын

    Concise and easy to understand, many thanks, Michael.

  • @channelname9468
    @channelname9468Ай бұрын

    great video bro, you explained this so much better and in like 1/30th the time of my teacher lmao

  • @MichaelSambol

    @MichaelSambol

    Ай бұрын

    thanks man!

  • @SuperOpposum
    @SuperOpposum3 жыл бұрын

    Man this video is old and I hope you see this, but it is the last I need to watch for my class. For an entire semester you managed to make my lecturer obsolete, saving me a LOT of time, and making things as clear as possible, I wish I could buy you a beer.

  • @MichaelSambol

    @MichaelSambol

    3 жыл бұрын

    I'll take you up on the beer, if I'm ever in your city :)

  • @SuperOpposum

    @SuperOpposum

    3 жыл бұрын

    @@MichaelSambol Well I got a 84 on my test, I'll buy you the entire brewery.

  • @miguelflor1600

    @miguelflor1600

    Жыл бұрын

    @@MichaelSambol és bueda da fixe

  • @fcmello1
    @fcmello16 жыл бұрын

    Thanks for helping, got a test today and explained much better than my professor. Thanks a lot :D

  • @Joophish
    @Joophish8 жыл бұрын

    fuck yes, simple. Hopefully this will help on my data structures test, though usually what you study the most is what the instructor completely leaves out.

  • @AaronccGuo
    @AaronccGuo8 жыл бұрын

    i liked the way you guys explain it, shor and clear.

  • @AvengersTrex
    @AvengersTrex7 жыл бұрын

    Short, simple and clear. Good work !! Many thanks to you

  • @WhoYaCallinPinhead804
    @WhoYaCallinPinhead8042 жыл бұрын

    Ok guys, it’s finals again and time to meet up with these youtubers the night before the test, to learn about a topic that we didn’t understand from professors taught weeks ago.

  • @jimboi95
    @jimboi9510 жыл бұрын

    Simple and straight to the point. Thankyou so much!

  • @MNKW123
    @MNKW1238 жыл бұрын

    Thank you!! Excellent explanation contrary to the million slides in my notes that are just plain confusing.

  • @joeyyshumm
    @joeyyshumm5 жыл бұрын

    Thank you so much. This is the clearest explanation I've seen

  • @winterfoxx6363
    @winterfoxx63632 жыл бұрын

    This channel is the best. I wish I watched these in college. Please make more videos on algorithms topics!

  • @emadharazi5044
    @emadharazi50444 жыл бұрын

    I did not think it was possible. Nicely done

  • @beani5355
    @beani53552 жыл бұрын

    Straight forward👏🏼nice one

  • @WVZEIJL
    @WVZEIJL7 жыл бұрын

    Thanks fam, your review and example vids are dank af

  • @ryandavis7506

    @ryandavis7506

    7 жыл бұрын

    haha didn't think I'd see the word 'dank' uttered in the comment section of an algorithms review video...classic

  • @WVZEIJL

    @WVZEIJL

    7 жыл бұрын

    Ryan Davis ayy got a 7.7 / 10 partly thanks to this guy

  • @yadvainderasood9728
    @yadvainderasood972810 жыл бұрын

    Short and comprehensive... Great job!!!

  • @sahilghuge5302
    @sahilghuge53024 ай бұрын

    Generational help done by u 😭🛐

  • @volo7
    @volo77 жыл бұрын

    what a fantastic video. seriously this is a great explanation shrunk to a 2 min video

  • @antarpreetsingh9038
    @antarpreetsingh9038 Жыл бұрын

    thank you, thank you so fucking much. You cant possibly from this planet. My fucking prof cant explain it in 2 hours and you fkin nailed it in 2 min. Glory to you sir. Mightly Michael Sambol.

  • @ejsafara456
    @ejsafara456 Жыл бұрын

    amazing, just what i wanted and needed

  • @seif7653
    @seif76532 ай бұрын

    my prof made this look like it's the hardest thing ever after talking to women. THANK YOU.

  • @BendenDrijver
    @BendenDrijver9 жыл бұрын

    This saved me so much time. Very clear and informative video, thank you!

  • @ElleMists
    @ElleMists Жыл бұрын

    either this discrete mathematics text book is actively trying to confuse me to lead me to fail, or you're a Godsend...probably both haha! thank you so very much, this was the best 1.5 minutes I've experienced today!

  • @MichaelSambol

    @MichaelSambol

    Жыл бұрын

    Thanks for watching, Elle! The code is linked in the description if you need it.

  • @miguelflor1600

    @miguelflor1600

    Жыл бұрын

    @@MichaelSambolés bueda da fixe

  • @matejpersic6601
    @matejpersic66015 жыл бұрын

    Thanks man! Just as your video on ford-fulkersons algorithm, simple and straight forward. Cheers

  • @AbdoAzmy2005
    @AbdoAzmy20052 ай бұрын

    11 years later, thank you very much

  • @MichaelSambol

    @MichaelSambol

    2 ай бұрын

    You're welcome!

  • @SOCAL_SHORTS_FACTORY
    @SOCAL_SHORTS_FACTORY7 жыл бұрын

    Saved me so much time. Thank you for great videos.

  • @rewinder802
    @rewinder8028 жыл бұрын

    short and sweet i like it. Keep up the good work!

  • @Abdullah-cm1tn
    @Abdullah-cm1tn3 жыл бұрын

    this ... was ... amazingly ... made ... simple ... OMG!!!

  • @miguelflor1600

    @miguelflor1600

    Жыл бұрын

    ele deu gosto porque é bueda da fixe

  • @avtaras
    @avtaras Жыл бұрын

    This is amazing, love this channel! Thank you :)

  • @MichaelSambol
    @MichaelSambol11 жыл бұрын

    u and v are vertices in the graph. {u,v} is the edge between those two vertices.

  • @user-hj2go1ur8i
    @user-hj2go1ur8i2 ай бұрын

    thank you bro, you are the real man

  • @Shoe_On_Head
    @Shoe_On_Head6 жыл бұрын

    summer test tomorrow for my discrete math class, ur a hero

  • @66saly
    @66saly7 жыл бұрын

    Short and clear review, thanks 👍

  • @whatthego
    @whatthego8 жыл бұрын

    Simple and no bullshit. Love it!

  • @XVIIArtemis
    @XVIIArtemis Жыл бұрын

    Holy shit thank you I was not about to watch a 30 damn minute video on how to do this

  • @MichaelSambol

    @MichaelSambol

    Жыл бұрын

    short and sweet

  • @miguelflor1600

    @miguelflor1600

    Жыл бұрын

    @@MichaelSambolés bueda da fixe

  • @prajaktadeosthali3083
    @prajaktadeosthali30838 жыл бұрын

    Thanks a lot for this short explanation!

  • @li-pingho1441
    @li-pingho14413 жыл бұрын

    The best tutorial ever

  • @gilbertvirgo5672
    @gilbertvirgo56727 жыл бұрын

    This is great, best Math video on KZread.

  • @curticelockhart87
    @curticelockhart875 жыл бұрын

    This was beautifully done, thank you!

  • @mohsenalbo5533
    @mohsenalbo55334 жыл бұрын

    dude your saving lives here

  • @putin_navsegda6487
    @putin_navsegda6487 Жыл бұрын

    sir thank you ! it's very clean and understandable explication !

  • @eunicefoo4499
    @eunicefoo44992 жыл бұрын

    You're amazing. Thank you !

  • @giannawilliams7037
    @giannawilliams70373 жыл бұрын

    ur the reason i might pass my ds/algo class

  • @nibrobb
    @nibrobb3 жыл бұрын

    Excellent explanation!

  • @Zeppelin-ep7uv
    @Zeppelin-ep7uv3 жыл бұрын

    excellent work, man!

  • @alimaydidthat
    @alimaydidthat Жыл бұрын

    bro changed my life