知识卡片

普通读书笔记卡 · 3644.c.3.a.1

Kruskal用并查集避环

理解等级:中级

Kruskal 按边权升序扫描。

  • 若两端点属于不同并查集,就收下该边并合并集合;
  • 若已属于同一集合,加入会成环,直接跳过。
这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 第21章 最小生成树 · 查看原书依据

      The for loop in lines 6–9 examines edges in order of weight, from lowest to highest. The loop checks, for each edge (u, v), whether the endpoints u and v belong to the same tree. If they do, then the edge (u, v) cannot be

    参考来源

    - 位置:《算法导论(第4版)》第21章《最小生成树》(OEBPS/chapter021.xhtml,文本字符[15000,20000))。 - 结论依据:原文伪代码先排序,再用 FIND-SET 判端点是否在同一树,收边后 UNION。 - 原始内容:The for loop in lines 6–9 examines edges in order of weight, from lowest to highest. The loop checks, for each edge ( u , v ), whether the endpoints u and v belong to the same tree. If they do, then the edge ( u , v ) cannot be