Minimum Spanning Trees
An MST connects all V vertices with V-1 edges at minimum total weight. Unique when all edge weights are distinct.
Cut property: The minimum-weight edge crossing any partition of vertices must be in the MST. This is why greedy works.
Union-Find (Disjoint Set)
class UnionFind:
def __init__(self, n):
self.parent = list(range(n))
self.rank = [0] * n
def find(self, x):
if self.parent[x] != x:
self.parent[x] = s
[Description truncada. Veja o README completo no GitHub.]