按秩合并 | 动画算法与数据结构

符号

数据
秩(节点的高度) rank

合併
比较秩 rank[x] > rank[y]:
将秩加 1 rank[y]++
更新父节点 parent[y] ← ?

动画

合併
按秩合并 | 合併