Six lessons. Six building blocks. You've seen each piece in isolation — initialization, find chains, path compression, union by rank, cycle detection, component counting. Each one solved a specific problem. Each one had a specific moment where you felt the need before you got the tool.
Now: can you deploy them together?
Below is a five-part assessment that tests across the entire module. You'll match real LeetCode problems to the right technique, assemble the complete UnionFind class from blanks, spot bugs that produce silent wrong answers, recognize when UF is the wrong tool entirely, and rapid-fire through the core facts.
This is not a teaching screen. There are no new concepts. Everything you need, you've already learned. The question is whether you can retrieve it under pressure and apply it to unfamiliar problem statements.
LC 684 — Redundant Connection
A tree with one extra edge. Find the edge that, when removed, leaves a valid tree.
Which UF technique does this problem need?
Here's the complete template — the same code you just assembled, with every optimization in place:
class UnionFind { parent: number[]; rank: number[]; components: number; constructor(n: number) { this.parent = Array.from({length: n}, (_, i) => i); this.rank = new Array(n).fill(0); this.components = n; } find(x: number): number { if (this.parent[x] !== x) { this.parent[x] = this.find(this.parent[x]); } return this.parent[x]; } union(a: number, b: number): boolean { const rootA = this.find(a); const rootB = this.find(b); if (rootA === rootB) return false; if (this.rank[rootA] < this.rank[rootB]) { this.parent[rootA] = rootB; } else if (this.rank[rootA] > this.rank[rootB]) { this.parent[rootB] = rootA; } else { this.parent[rootB] = rootA; this.rank[rootA]++; } this.components--; return true; } connected(a: number, b: number): boolean { return this.find(a) === this.find(b); }}The trigger recognition checklist — when you see these patterns in a problem, reach for Union-Find:
connected() call. LC 547, 990.find(u) === find(v) before union = cycle. LC 684.components = n - successful merges. LC 323, 200, 547.When NOT to use Union-Find:
Six lessons built one data structure from scratch. You started with a buggy constructor and ended with a tool that solves connectivity, cycle detection, and component counting — all through the same parent-pointer forest.