Criterion | Prim’s Algorithm | Kruskal’s Algorithm
------------------------------- | --------------------------------------------------------------------- | -------------------------------------------------------------------------
Approach | Starts from one vertex and adds the smallest connected edge each time | Sorts all edges first and adds them one by one if they don’t make a cycle
Time complexity | O(E log V) with a priority queue | O(E log E) because of edge sorting
Data structure used | Uses adjacency list or matrix and a priority queue | Uses edge list and union-find (disjoint set)
Best suited for | Works better on dense graphs | Works better on sparse graphs
Ease of implementation | Easier when graph is in adjacency matrix form | Easier when graph is in edge list form
Execution speed (practical) | A bit slower on large sparse graphs | Usually faster on sparse graphs