[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge pull request #146 from wangxinalex/patch-2
Browse files Browse the repository at this point in the history
Update 01.Union-Find.md
  • Loading branch information
itcharge committed Jun 27, 2024
2 parents 97feab7 + 95740e9 commit 9083ce3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Contents/07.Tree/05.Union-Find/01.Union-Find.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class UnionFind:
self.fa[root_y] = root_x # y 的根节点连接到 x 的根节点上,成为 x 的根节点的子节点
else: # x 的根节点对应的树的深度 等于 y 的根节点对应的树的深度
self.fa[root_x] = root_y # 向任意一方合并即可
rank[y] += 1 # 因为层数相同,被合并的树必然层数会 +1
rank[root_y] += 1 # 因为层数相同,被合并的树必然层数会 +1
return True

def is_connected(self, x, y): # 查询操作:判断 x 和 y 是否同属于一个集合
Expand Down

0 comments on commit 9083ce3

Please sign in to comment.