Introduction
Kruskal’s algorithm is used to find the minimum/maximum spanning tree. A minimum spanning tree is a spanning tree whose weight is as small as possible.
Implementation
Complexity
-
Time complexity: or
- Sorting edges:
- Union-Find operations: , where is the inverse Ackermann function
- Since grows extremely slowly and is effectively constant, this becomes
- Overall complexity is dominated by the sorting step
-
Space complexity:
- Edge list:
- Union-Find data structure: