Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a problem with code #197

Open
zhangbo2008 opened this issue Nov 24, 2021 · 4 comments
Open

a problem with code #197

zhangbo2008 opened this issue Nov 24, 2021 · 4 comments

Comments

@zhangbo2008
Copy link

if proot == len(uf.parent)-1 {

感觉这个地方应该是:

应该是 uf.count[proot]== len(uf.parent)-1

@hekai000
Copy link

对,这里有问题,应该是:
if uf.count[proot ] == len(uf.parent)-1 {
//proot is the root of the tree, no need to merge
} else if uf.count[qroot] == len(uf.parent)-1 {
proot , qroot = qroot, proot
} else if uf.count[qroot] > uf.count[proot] {
proot , qroot = qroot, proot
}

@haowan1015
Copy link

haowan1015 commented Sep 20, 2024 via email

@xiaokuer
Copy link

xiaokuer commented Sep 20, 2024 via email

@halfrost
Copy link
Owner

@zhangbo2008 我这里的 proot 和 qroot 只是代表 index,存的 count 是在 uf.count[proot] 中。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants