您当前的位置: 首页 >  数据结构与算法

【数据结构与算法】非森林版并查集V1.1的Java实现

星拱北辰 发布时间:2020-02-23 15:42:49 ,浏览量:4

并查集

并查集是重要的数据结构,在算法编写中很常见。 这里写的比较平实,不使用联合启发式或路径压缩算法。 集合中的元素从0开始编号。 可结合着看:并查集V1.0——森林版。

核心功能
  • void union(root1, root2) → Merge two sets
  • int find(x) → Return set containing x
编程实现
/**
 * Disjoint set class.
 * Does not use union heuristics or path compression.
 * Elements in the set are numbered starting at 0.
 */
class DisjSetsSlow {
   

    private int[] set;

    /
关注
打赏
1688896170
查看更多评论

星拱北辰

暂无认证

  • 4浏览

    0关注

    1201博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.5213s