Skip to content
GraphsConnectivitycore

Union–Find

Tracks which vertices belong to the same connected component while edges are added one by one. Union by rank keeps the forest shallow and path compression flattens it further — both are drawn live, so you can watch pointers snap straight to the root.

Best
O(α(n))
Average
O(α(n))
Worst
O(α(n))
Space
O(V)