Level 4 · Advanced
Free Union-find lessons
4 lessons, about 32 minutes in all. Each teaches one idea with a visual, then gives you one problem built for it. Read the lessons here, then create a free account to solve the problems and keep your progress.
Stage 0Groups that merge
- Are they in the same group?Every node starts in its own group; keep a parent array and follow it up to find each group's root.9 min
- Count the groupsStart with n groups, and lose one every time a merge actually joins two different groups.7 min
- Largest groupTrack each root's group size alongside parent, and add sizes together whenever two groups merge.8 min
- Spotting a redundant linkA merge that finds the same root on both sides didn't need to happen; count how often that occurs.8 min
There’s more after this
These are the opening stages of Union-find. The full path climbs on to harder problems and a mastery test. Create a free account and we’ll keep your place.
Start the full path free