Prim's Algorithm: Minimum Spanning Tree (MST)

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024
  • Short example of Prim's Algorithm, graph is from "Cormen" book.

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

  • @nahux
    @nahux 6 ปีที่แล้ว +173

    This is the most clear explanation I've seen. It contemplates everything, Thank you!!

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

      thank you so much!

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

      I wish I could agree, but there was not explanation why we must consider all the edges that he rattled off after getting to a node.

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

      @@jacoblopez6365 was pretty clear to me to be honest

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

    saved me during finals man absolute stud

  • @chrisklecker
    @chrisklecker 6 ปีที่แล้ว +8

    You really should explain this using a queue as this is really the back bone behind this algorithm and is an easy way to show how to choose a path.

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

      that is true, i should have. Maybe i ll upload another one

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

    Thank you so much. I was baffled with so many videos.But yours tutorial took my concepts on the track.

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

      thank you very much! i am glad my videos are helpful

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

    I thought I had my answer at about :20 into the video
    But I wanted to make sure so I watched until about 1:30 and my answer was confirmed
    About 1:30 plus the 2 minutes searching google to find your video or "read" 40 pages of death to maybe find the same conclusion
    I'll pick the 2 and a half minutes with you every time! thanks for this awesome video that cut the BS and got straight to business - no frills no BS new subscriber!

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

    Note: the spanning tree is not unique. Removal of edge (b,c) and replacing it with (a,h) gives a spanning tree with the same total distance.

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

      thank you, just finished coding and my algorithm chooses a-h first

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

    Your video helps me a lot. Thank you for your great work!

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

    this is an excellent explanation. This will definitely help me for my data structures exam

  • @MyFictionalChaos
    @MyFictionalChaos 3 ปีที่แล้ว +8

    No wonder they say it's a surprisingly easy algorithm! And yet quite difficult to teach for some

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

    This totally helped me, you're explanation is clearer. Thank you!

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

    Made me understand it in minutes!! Thank you!

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

    6 years later and it still helps students like me

  • @VARUN-gn5kq
    @VARUN-gn5kq 3 ปีที่แล้ว +1

    Watching your video Once again To revise topic one day before my End term❤️✔️
    Thanku for lovely video

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

      Hope you did great :)

    • @VARUN-gn5kq
      @VARUN-gn5kq 3 ปีที่แล้ว

      @@EducateYourselfNow yes sir!! But actually this topic which i prepared for did nt come in exam!!

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

    You are such a dope bro,Thank you!

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

    Well done - the part about no cycles are not emphasized in other videos.

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

    Woah i was making a table but this is really easy the way you have done thanks alot.

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

    Thank you so much!

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

    Thanku for uploading this video because this is usefull for student like me.

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

    A perfect explanation. Thanks :)

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

    Cool explanation

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

    nice work.thank you so much.it has another alternative solution no?

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

    0:57s does arbitary vertex in the sense means any vertex of my choice ?

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

    What is the differnce between minimum spanning tree and a minimmal spanning tree of a graph?

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

      MST of the graph is a regular MST as well.

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

    So is it safe to say, that this video finds the shortest solution one could travel to get to all locations? Meaning that every node must be reachable, but it's the most effecient way to reach all nodes? I'm strugling with this a bit because you could take the road from A to H and get there much faster that going way around.

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

    Does it mean that we have to stop selecting edges until most edges that do not form a cycle will be selected? Then that would be the time the MST is already completed?

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

    That's a lot simpler way than it's taught in CS! Love it!

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

    Its help me so much..thank you..
    Btw, ur voice sound a little bit like harry style..

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

    Really helpful thanks!

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

    nice explanation. Thanks for sharing!!!!

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

    Perfect! Thanks

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

    You make it simple thank you

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

    i dont understand, why should we take c-d that cost 17, when e-f cost 10 and doesnt cause any loop

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

    How it will help us to find a shortest path????...

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

    Thanks my hero

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

    At 5:46 how would edge 11 create a cycle?

  • @SY-uh8vs
    @SY-uh8vs 6 ปีที่แล้ว +2

    Thanks. Total is 37

  • @AlfataAlfaet
    @AlfataAlfaet 7 ปีที่แล้ว +8

    at 5:01, why didn't you consider g to i because cost is 6 which is less than 7? i know it will create a loop but you did not even mention it? is there a reason or you just overlooked it by mistake ? thank you

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

      good catch, yes I forgot to mention that 6 is the lowest but it will create a loop and that is the reason why I didn't choose it.

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

      at 4:44 "number 7 seems to be the lowest out of all of them. pay attention we can't choose this as it will create a cycle and we can't have a cycle in prim's algorithm."

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

      Because you keep track of previously visited vertices. At this point, I and G are already visited.

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

    Thanks sir🤗

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

    thank you so muchhh!!!

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

    Thanks!

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

    Thanks a lot!

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

    best explanation XD

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

    Color the visited nodes or manage list to detect cycle !!!
    Dont take edge with 2 visited nodes...

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

    Good

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

    what will be cost of this graph??

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

    Nice

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

    thanks bro..it is helpful

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

    thanks a lot man!!!

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

    TY m8 :))))

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

    Great 😍

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

    thank you

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

    why u dont choose f to e ?

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

      One must cover all the vertices on the graph using smallest unit to get there, the reason why i didn't choose f to e instead of d to e is because f to e has a higher cost to get to e than d to e since from d to e costs 9 and f to e costs 10.

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

      in simplest terms, you are just picking out smallest distances between two vertices without creating a cycle

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

      thanks

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

      cost is high

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

    can i get the code for this?

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

    cheers lad

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

    You are wrong in prim's we select least cost vertex
    So we select h to g vertex instead of a to b

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

    POST MORE VIDEOS

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

    You open by saying Prim is the same as Kruskal. This is NOT true. Please be precise.

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

    gud 1

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

    Do you have Facebook or twitter ? I have question in math

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

      Unfortunately I don't, but feel free to message me directly on TH-cam.

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

      EducateYourself I sent you but I don’t know you read it or no .

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

      Just saw the message

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

      EducateYourself I want to application of the minimum wight rooted arborescence problem and i want to write an algorithm for minimum wight rooted arborescence problem in acyclic digraphs How to write.

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

    EE241C5A ftw!!!

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

    Finally a non-indian version, sick of these videos by indian guys with their accents

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

    Everything is clear except the writing

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

    MST is not similar to dijkstra it is used to find cost of min spanning tree...not shortest path

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

    awesome video man, was struggling at first to get the concept and you helped nail it down for me. thank you!

  • @Psydle_
    @Psydle_ 7 ปีที่แล้ว +23

    Thanks, you confirmed that my professor messed up in grading our homework, thanks

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

      Get as many points as possible, they add up at the end.

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

    Great explanation! Much better than my book and I finally understand it

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

    How would you do it if you can’t backtrack? You went from C to I and the C to F. If you had to continue from the last point you reached, how would you make it efficient?

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

    Thanks a lot ....after a lot of search I got this helpful explanation.

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

    Brilliant! Thank you for your clear explanation.

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

    For the last move as you said we have choice between 9, 10 and 11 I think choosing the edge b-h was not a choice. it would have been a cycle.

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

    this was so clear like you explained it better

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

    I never comment on any video on youtube :-) but seriously u deserve a BINGO ..... THANK YOU

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

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

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

    mannn .. that was so simple. Really helped me a lot.

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

    Simple and easy. Great job dude!

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

    This is a great video. Thank you so much! God bless :)

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

    Thanks so much! this is such a great video!

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

    Ur the best other just use a small path so it makes this algorithm unclear but u use long path to show this. GOOD WORK!

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

    Thank you very much! Greetings from Italy!

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

    I HONESTLY SPEND AN ENTIRE DAY LOOKING FOR A GOOD SOLUTION TO PRIMS AND I AM SO HAPPY I FOUND IT. THANK YOU SO MUCH FOR THIS . YOU GOT A NEW SUBSCRIBER

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

      i am glad i can help :) thank you so much for the sub!

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

      love you from the bottom of my heart. now i can make all my friends beg me to help them HAHAHAHAHA

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

      lol unless they see this video

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

    Thanks a million Sir 👍👌🔥
    4 years before but hasn't lost the charm 👍

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

    i still dont understand my lecturer give me question to find the shortet path from A to J

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

    Nice explanation in a short amount of time..!!Keep it up!!!Thank you so much :)

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

    Nice Work man :)

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

    best explanation for prims algo that I've found

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

    I have a question b-c and a-h are basically ties because their distances are the same so why after choosing a-c did we not choose a-h ? But rather chose c-i ?

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

      because we were at the node "c", and least costly edge from "c" is to "i"

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

    wow using this video i understood it completely

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

    I have a Decision Sciences exam on Monday (today being Saturday 1am) and you helped me cover 20% of a section in 6 minutes. Thank you kind sir

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

      i am glad i could help, thank you for the comment!

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

    Wonderful explanation. Thank you!

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

    at 5:17 we can not select AH not only because it would create a cycle but because A and H are already discovered before...so there is no need in examining those 2 edges at that moment
    Great explanation though!! clear and to the point!!! love your videos on Kruskal's and Dijkstra as well!! :D

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

    bless you, sir

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

    Great explanation than my lecturer

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

    Do we determine a node to start? Or we just start?

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

      you can start on any node which will still give you the same minimal possible weight st, however, it may result in a different mst.

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

    my code chooses a-h instead of b-c, is this wrong or ???

  • @rajithaprasad-t8i
    @rajithaprasad-t8i 2 หลายเดือนก่อน

    You save my day man. Thanks... 🤩

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

    Thanks :)

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

    This man sounds like Nico Rosberg lol

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

    Very Useful😆

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

    Thanks for this video brother👍

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

    +I don't understand. The route a h g f e has a spanning tree of 21, which seems the shortest to me. So the algorithm doesn't really work?