menu search
brightness_auto
more_vert
differentiates between Prim's Algorithm and Kruskal's Algorithm:
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

1 Answer

more_vert
 
verified
Best answer
Prim's Algorithm Kruskal's Algorithm
A greedy algorithm that finds the minimum spanning tree (MST) of a weighted undirected graph. Another greedy algorithm that also finds the minimum spanning tree of a weighted undirected graph.
Starts with a single vertex and gradually expands the tree by adding the cheapest edge that connects the tree to a new vertex until all vertices are in the tree. Sorts all the edges in non-decreasing order of their weights and then gradually adds edges to the tree, skipping those that create cycles, until all vertices are in the tree.
Uses a priority queue to keep track of the cheapest edges to add to the tree. Uses a union-find data structure to keep track of which vertices are connected and avoid creating cycles.
Can have different outputs depending on the starting vertex. Always produces the same output regardless of the starting vertex.
Has a time complexity of O(E log V) using a binary heap for the priority queue. Has a time complexity of O(E log E) using a sorting algorithm to sort the edges.
Good for dense graphs (many edges) where E is close to V^2. Good for sparse graphs (few edges) where E is much smaller than V^2.
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike

Related questions

thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
0 answers
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
0 answers
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
0 answers
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
1 answer
thumb_up_off_alt 0 like thumb_down_off_alt 0 dislike
1 answer

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

648 users

...