Path Compression — Flattening a DSU Tree

Controls

Builds a tall chain 0→1→…→n-1 (root on top).
Run a single find from the chosen node and watch the path get re-pointed.

Stats

Modefull
Path length walked
Pointer rewrites0
Root found
Avg depth (all nodes)

Legend

root (parent[r]==r)
current node in walk
on the find-path
just re-pointed

Forest

Build a chain, then run find(0). Toggle Full / Halving / Splitting to compare how each variant rewrites parents.

parent[] array