知识卡片

普通读书笔记卡 · 3634.a.6.b

路径压缩让查找路径直连根

理解等级:中级

路径压缩在 FIND-SET 找到根后,让本次查找路径上的节点直接指向根。

它缩短后续查找,但不改变集合成员或节点秩;未访问的其他路径不必在这次操作中改写。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《算法导论(第4版)》第19章《不相交集合的数据结构》(OEBPS/chapter019.xhtml,文本字符[15000,20000))。 - 结论依据:原文描述FIND-SET沿途节点改为直指根且秩不变。 - 原始内容:The second heuristic, path compression , is also quite simple and highly effective. As shown in Figure 19.5 , F IND -S ET operations use it to make each node on the find path point directly to the root. Path compression does not change any ranks.