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

DSU datastructure: map <ll,ll> urank doesn't work #6

Open
sparsh2 opened this issue Jul 23, 2019 · 1 comment
Open

DSU datastructure: map <ll,ll> urank doesn't work #6

sparsh2 opened this issue Jul 23, 2019 · 1 comment

Comments

@sparsh2
Copy link

sparsh2 commented Jul 23, 2019

void create(ll x) { parent[x] = x ; urank[x] = 0 ; // rank = no. of nodes in its subtree }

In the above create function, urank[x] has to be set to 1. If not this does not serve any purpose. urank of any element will always remain 0

@salmandotexe
Copy link

Agreed, it was previously 1, idk why it was set to 0.
in the merge function there should also be a check if xroot==yroot then return. but urank[x] =0; is a major issue.

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

2 participants