Union-find over 0..size-1 with union by rank and path compression, ~$O(\alpha(n))$ per op.
0..size-1
Merges the sets of left and right; returns false when already joined.
left
right
Union-find over
0..size-1with union by rank and path compression, ~$O(\alpha(n))$ per op.