LeetCode Prep
Algorithm Visualizer
Step through two pointers, sliding window, binary search, BFS/DFS, heaps, DP, and union-find one operation at a time.
← All visualizers
≈ O(α(n)) per operationUnion-Find with Path Compression
Merge components by rank and flatten find paths so connectivity queries become nearly O(1).
| node | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|---|
| parent | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| rank | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Edges left0–12–31–34–55–66–74–73–7
1/358 nodes, each its own component. Process the edges one by one.
Keyboard: ← → step · Space play/pause