๐ฎ Union-Find (Practice)
Companion to the Union-Find guide. Watch disjoint sets merge as edges are added, then implement DSU with path compression.
๐ฌ Watch it workโ
Union-Find โ merging disjoint setsStep 1 / 5
6 singleton sets. Union-Find merges them.
๐ Your turnโ
Loading editorโฆ
๐ง Challenge yourselfโ
- Count the number of connected components after all unions.
- Use DSU to detect a cycle in an undirected graph.
- Why does path compression + union by size give near-O(1) amortized?
Continue the path โ Greedy Algorithms