Kruskal's builds the cheapest network by always choosing the cheapest connection.
It sorts all edges by weight and adds them one by one, skipping any that would create a loop.
Total Weight: 0
Edges in MST:
Kruskal's algorithm uses a Union-Find data structure to detect cycles. Think of it as building bridges between islands - we always choose the cheapest bridge that connects two separate islands.
Loading code...