Two nodes are connected when their roots are the same.
Union Find
5 chapters · 6 challenges · The Connected Expanse
Understand the idea, practise through play, then prove it in code. Choose your next quest below.
Visual introduction to this topic
What is union find?
Union find maintains disjoint groups while connections are added. It answers whether two items share a representative and merges their groups efficiently.
Think of forming alliances. Each player follows a captain. When two alliances merge, only their captains need to be connected; everyone inherits the new group.
Find a representative; union representatives; compress the route for next time.
Attach the smaller or shallower tree to the larger one.
Make every visited node point closer to the root after a find.
Merge direct roads into connected regions
Components
0/2 completePractice components through 2 visual expeditions.
Path Compression
0/1 completePractice path compression through 1 visual expedition.
Union By Rank
0/1 completePractice union by rank through 1 visual expedition.
Redundant Edge
0/1 completePractice redundant edge through 1 visual expedition.
Offline Connectivity
0/1 completePractice offline connectivity through 1 visual expedition.
Built from authoritative material
This track is checked against the sources below. Visual traces still carry their own complete or guided coverage label, so unfinished explanations are not presented as complete executions.