Kruskal's Algorithm: Minimum Spanning Tree (MST)

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.พ. 2025
  • Example of Kruskal's algorithm

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

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

    When I get my degree after next semester, I'll raise a cheers to you for helping me get through algorithms!

  • @countchungalitus7604
    @countchungalitus7604 3 ปีที่แล้ว +37

    Studying for my data structures exam that is in... four hours. Your videos on Kruskals, Prims, and Dijkstra's are saving my life because I missed those lectures. Cheers mate!

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

    I thought it was my laptop's fan that sounds so loud when i listened to the audio. I panicked for a sec. But thanks! This really helped a lot!

  • @Alkis05
    @Alkis05 3 ปีที่แล้ว +15

    One improvement I would make would be this: When choosing between two edges with the same weight, choose randomly between them, but give a probability weighted by the degree of the node you are connecting to. In many real life networks, nodes with high degree tend to receive more new nodes than less connected nodes.

  • @monaami555
    @monaami555 8 ปีที่แล้ว +116

    "the main thing is, you can't have any psychos" - agree!

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

      LOL........
      I am latin and members of my family speak with an accent.

    • @user-rf4vc7mt4d
      @user-rf4vc7mt4d 3 ปีที่แล้ว

      SCAM

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

      He means *_cycles_*

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

    Again, short and simple to the point great video.

  • @gongjiaji2489
    @gongjiaji2489 6 ปีที่แล้ว +31

    thank you very much, i have exam tomorrow

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

    dope !!!!! thanks for this video. you just did 10 times better than my professor at cal state Monterey Bay

  • @sirch1984
    @sirch1984 7 ปีที่แล้ว +6

    Thanks for helping me with my hw, you rock my dude

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

    if you also circle the vertices you've visited red, choosing the next edge/vertex pair will become easier without having to look through the entire graph to check for a cycle

    • @EducateYourselfNow
      @EducateYourselfNow  7 ปีที่แล้ว

      that is true, didn't think of that, thank you. i ll incorporate that in my upcoming videos

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

      thats not correct. 3:00 would fail. you have to maintain a en.wikipedia.org/wiki/Disjoint-set_data_structure

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

    THIS VIDEO IS JUST 🔥🔥🔥🔥 THX A LOT MAN!!!!!

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

    thank you man! i finally understand it

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

    very nice explanation

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

    bro just increase the thickness of the pen 😂😂

  • @MarkedMuichiro828
    @MarkedMuichiro828 6 ปีที่แล้ว +7

    Nice explanation. Thank you.

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

      I agree. Thank you so much for posting this video!

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

    Dude i love you man

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

    i have exam tomorrow thanks man i got it

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

    what a king, ty

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

    very nice explained video! Thank you

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

    Nice work man :)

  • @JC-cu2ym
    @JC-cu2ym 4 ปีที่แล้ว +1

    THANKS FOR SAVING MY LIFE :D !!!!

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

    Good video, help me a lot

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

    Thank you for this!! (you have a nice voice though god)

  • @xxakhilh47xx41
    @xxakhilh47xx41 7 หลายเดือนก่อน +2

    Lifesaver

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

    Awesome sir😍😍

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

    U r explanation too gud...pls explain bellmanford algorithm also....

  • @zepheriah5294
    @zepheriah5294 6 ปีที่แล้ว +7

    You said that since you decided to pick the edge with amount 8 from B - C, you couldn't pick the edge amount with 8 also from A - H because it wasn't a part of the same tree. Why is that? I thought all of the vertices were in one tree? What is the criteria on that?

    • @EducateYourselfNow
      @EducateYourselfNow  6 ปีที่แล้ว +10

      The reason why we can't choose a-h after choosing b-c is because it would form a cycle. Yet if we have chosen a-h instead of b-c, we would have a different resulting MST. You can have multiple MST from a single graph.

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

      @@EducateYourselfNow Duh! Thank you!

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

    THANK U SO MUCH FOR THIS

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

    the path you choose is not the shortest path

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

    Pretty nice, thanks.

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

    so it means that the objective of this algorithm is to find the lowest edge-weights?
    and then it should start also in the lowest number of weights?
    thanks sir, btw you did a great job, i',m just a little bit confused because i don't know the rules of this algorithm.

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

      well to find the minimum cost edges, which would eventually result mst. its a greedy algorithm, it doesn't necessarily start at the lowest number of weights but it will find them. and thank you sir

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

    1. how does adding edge (b,h) with edge weight 11 form a cycle?
    2. adding (c,i) and (g,f) with edge weight 2 is fine but adding (b,c) and (a,h) with edge weight 8 is a problem.
    can you elaborate?

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

      1. with (b,h), it will loop the diagram. This means you will be creating a cycle where it goes from b, h, g, f, c, b. You do not want the arc/edge to be in a cycle (loop). Not connecting (b,h) means that there is no loop created. 2. Adding (c,i) and (g,f) is fine because they will not create a cycle, so you pick both. (b,c) and (a,h) is only a problem because you can not pick both as that will create a loop/cycle. But he states that you can pick either one as either (b,c) or (a,h) as there will sometimes be multiple minimum spanning trees (alternative paths).

  • @ahmedmagdy-qg3tb
    @ahmedmagdy-qg3tb 6 ปีที่แล้ว +1

    good job

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

    Given completely distinct edges in graph G, there is only a single MST.

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

      Given a graph G lets prove this by contradiction:
      G has two MST A,B.
      A has an edge e that B does not
      If we add that edge to B then there is a cycle.
      However, k. Algo would have picked the edge e0 over e therefore, A must not be in mst.

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

    Ok, how do we get the lowest weighted edges? How do we find if adding an edge would form a cycle? Isnt explaining this the point of these videos?

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

    why did not you choose both edges with weight 8?

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

    thank you

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

    Thanks bro

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

    Is this the same as minimum cost arborescence?

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

    Thank you so much! XD

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

    thanks

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

    Can someone explain what he mains by cycle more?

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

    How do you programmatically test if adding the edge will form a cycle?

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

    if we have touched all the vertices but not all the edges yet what should i do? finish all the edges?

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

    can anyone explain why did not we consider the other 8

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

      we could, it wouldn't have mattered. I think i mentioned it in the video. 3:07

    • @MsKevkev1234
      @MsKevkev1234 7 ปีที่แล้ว +3

      if he did it would form a loop abcfgha

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

    thx bro

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

    thanks a lot man its very helpful
    answer is 42 ??

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

      Isn't it 37?

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

      @@marieselfer6621 i think its 37 too

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

      @@Brrrzna291 Maybe another spanning tree would get a lower total cost than 37?

  • @HauNguyen-mb3si
    @HauNguyen-mb3si 6 ปีที่แล้ว +1

    Thanks

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

    Dikjstra algo??

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

    how do you get those numbers?

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

    It looks like C would form a cycle. Am I missing something?

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

    In the Time Complexity part, you definitely gave a description of the runtime of the Prim's algorithm, not Kruskal's.

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

    Thank u sir

  • @dabluedevil1000
    @dabluedevil1000 7 ปีที่แล้ว

    How would choosing the edges "bh" create a cycle?

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

    well you could remove the c-d, and replace it with e-f. i think it will produce better MST

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

    BIG O!

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

    so whats difference btw prims

    • @EducateYourselfNow
      @EducateYourselfNow  7 ปีที่แล้ว +14

      at a very high level, prims algorithms graph has to be connected, kruskals doesn't, in kruskals, you look at the next globally least costly edge where in prims you look at all edges from the current component to other vertices and find the smallest among them.

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

    EE241C5A ftw!!!

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

    Can't understand about algorithm

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

    why did you choose both the two

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

      because the next two was the lowest costly edge, it doesn't matter how many of the same numbers you have, as long as it doesn't create a cycle, you can choose it.

    • @almuntasirabir4511
      @almuntasirabir4511 7 ปีที่แล้ว

      thanks

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

      But is it still minimal is the question.

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

      @@niklaspeura4193 Yes, why would this give a minimal spanning tree?

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

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

    I hate discreet mathmatcis

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

    u such a copy ninja (from book introduction of algorithm)