Why prims algorithm is better than kruskals algorithm?

1 answer

Answer

1181560

2026-05-12 09:50

+ Follow

"What are difference between Prim's algorithm and Kruskal's algorithm for finding the minimum spanning tree of a graph?"

Prim's method starts with one vertex of a graph as your tree, and adds the smallest edge that grows your tree by one more vertex. Kruskal starts with all of the vertices of a graph as a forest, and adds the smallest edge that joins two trees in the forest. Prim's method is better when * You can only concentrate on one tree at a time * You can concentrate on only a few edges at a time

Kruskal's method is better when * You can look at all of the edges at once * You can hold all of the vertices at once * You can hold a forest, not just one tree

Basically, Kruskal's method is more time-saving (you can order the edges by weight and burn through them fast), while Prim's method is more space-saving (you only hold one tree, and only look at edges that connect to vertices in your tree).

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.