Union By Rank |
會動的演算法
符號表示
資料
節點的高度
rank
合併
比較節點高度。
rank[x] > rank[y]:
將高度加 1。
rank[y]++
更新父節點。
parent[y] ← ?
演算法動畫
合併