知识卡片
按秩合并让矮树接高树
按秩合并为节点保存“高度上界”秩,让秩较小的根接到秩较大的根;两根同秩时任选父根并把其秩加一。
秩并非压缩后的实时高度,不能因路径压缩而重算它。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 第19章 不相交集合的数据结构 · 查看原书依据
For each node, maintain a rank, which is an upper bound on the height of the node. Union by rank makes the root with smaller rank point to the root with larger rank during a UNION operation.
参考来源
- 位置:《算法导论(第4版)》第19章《不相交集合的数据结构》(OEBPS/chapter019.xhtml,文本字符[15000,20000))。
- 结论依据:原文定义秩为高度上界和小秩根挂大秩根,后文补充同秩加一。
- 原始内容:For each node, maintain a rank , which is an upper bound on the height of the node. Union by rank makes the root with smaller rank point to the root with larger rank during a U NION operation.