Differences between Prim's and Kruskal's algorithms?

Maths and statistics discussion, revision, exam and homework help.

Announcements Posted on
Please change your TSR password 23-05-2013
Enter our travel-writing competition for the chance to win a Nikon 1 J3 camera 20-05-2013
IMPORTANT: You must wait until midnight (morning exams)/4.30AM (afternoon exams) to discuss Edexcel exams and until 1pm/6pm the following day for STEP and IB exams. Please read before posting, including for rules for practical and oral exams. 28-04-2013
Sign in to Reply
  1. James's Avatar
    • Vengeful, Imperial Overlord of The Student Room
    • Posts: 3,840
    Differences between Prim's and Kruskal's algorithms?
    I've read the Edexcel D1 textbook over and over, and I can't get it clear in my head what the difference is between Kruskal's and Prim's algorithms for finding minimum spanning trees.

    Can anyone clarify?
  2. CalculusMan's Avatar
    • Peer Of The TSR Realm
    • Location: --
    • Posts: 1,405
    Re: Differences between Prim's and Kruskal's algorithms?
    Kruska's builds a minimum spanning tree by adding one edge at a time. The next line is always the shortest (minimum weight) ONLY if it does NOT create a cycle.

    Prims builds a mimimum spanning tree by adding one vertex at a time. The next vertex to be added is always the one nearest to a vertex already on the graph.
  3. edmundwillis's Avatar
    • Exalted Member
    • Posts: 269
    Re: Differences between Prim's and Kruskal's algorithms?
    The attachments are from an OCR (MEI) cheatsheet but I am sure Edexcel will tackle these questions in the same way.

    Hopefully, they make the different methods simple enough.
    Attached Thumbnails
    Click image for larger version. 

Name:	kruskal.GIF 
Views:	2976 
Size:	21.6 KB 
ID:	23571   Click image for larger version. 

Name:	prim.GIF 
Views:	2834 
Size:	18.6 KB 
ID:	23572  
  4. Christo's Avatar
    • Peer Of The TSR Realm
    • Location: Belfast
    • Posts: 1,702
    Re: Differences between Prim's and Kruskal's algorithms?
    Prim always joins a "new" vertex to an "old" vertex, so that every stage is a tree. Kruskal's allows both "new" to "new" and "old" to "old" to get connected, so it risks creating a circuit and must check for them every time. So Kruskal's has a larger complexity than Prim.
  5. declique's Avatar
    • Junior Member
    • Location: Bucharest
    • Posts: 50
    Re: Differences between Prim's and Kruskal's algorithms?
    (Original post by James)
    I've read the Edexcel D1 textbook over and over, and I can't get it clear in my head what the difference is between Kruskal's and Prim's algorithms for finding minimum spanning trees.

    Can anyone clarify?
    Here you find the best answer: http://stackoverflow.com/questions/1...ruskal-vs-prim

    However, try and understand each algorithm - wikipedia is a good start.
  6. tehforum's Avatar
    • TSR Legend
    • Location: England
    Re: Differences between Prim's and Kruskal's algorithms?
    (Original post by declique)
    Here you find the best answer: http://stackoverflow.com/questions/1...ruskal-vs-prim

    However, try and understand each algorithm - wikipedia is a good start.
    Sorry, you're a bit late.

    5 years late.
  7. declique's Avatar
    • Junior Member
    • Location: Bucharest
    • Posts: 50
    Re: Differences between Prim's and Kruskal's algorithms?
    (Original post by tehforum)
    Sorry, you're a bit late.

    5 years late.
    Are you from the late police? This is the 3rd result in Google for "prim kruskal" so I didn't do it for the OP but for the people who get here from Google results.
    But, yes... assume I don't know to read when this was posted.
  8. tehforum's Avatar
    • TSR Legend
    • Location: England
    Re: Differences between Prim's and Kruskal's algorithms?
    (Original post by declique)
    Are you from the late police? This is the 3rd result in Google for "prim kruskal" so I didn't do it for the OP but for the people who get here from Google results.
    But, yes... assume I don't know to read when this was posted.
    Oh sorry, my mind reading machine wasn't working at that precise moment.

    My bad.
  9. Bobifier's Avatar
    • TSR Demigod
    • Location: England
    • Posts: 5,613
    Re: Differences between Prim's and Kruskal's algorithms?
    Prim's is easier to draw.

    Aside from that, Prim's selects edges only from the set of edges that are adjacent to those you have already put in your tree. Kruskal's selects edges from the set of all possible edges.
  10. mattys851's Avatar
    • New Member
    • Posts: 1
    Re: Differences between Prim's and Kruskal's algorithms?
    (Original post by edmundwillis)
    The attachments are from an OCR (MEI) cheatsheet but I am sure Edexcel will tackle these questions in the same way.

    Hopefully, they make the different methods simple enough.
    you sir may have just got me the B I need in maths!
  11. the bear's Avatar
    • TSR Demigod
    • Location: Linton Travel Tavern
    • Posts: 7,204
    Re: Differences between Prim's and Kruskal's algorithms?
    i like Prim's... i used not to like the matrix method but it is OK now

    one of my textbooks says you should also check that Prim's does not form a cycle but i guess that is just a mistake.

    Prim's reminds me of Pimms...
  12. rashi b's Avatar
    • New Member
    • Posts: 1
    Re: Differences between Prim's and Kruskal's algorithms?
    then why is prims algorithm easily adapted to a distance matrix??
Sign in to Reply
Share this discussion:  
Article updates
Moderators

We have a brilliant team of more than 60 volunteers looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

Reputation gems:
The Reputation gems seen here indicate how well reputed the user is, red gem indicate negative reputation and green indicates a good rep.
Post rating score:
These scores show if a post has been positively or negatively rated by our members.