Last active
September 12, 2020 15:21
-
-
Save asutoshgha/142e0c93ed072c81b1637b72e8de26d3 to your computer and use it in GitHub Desktop.
disjointsetwithpathcompression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int parent[1000]; | |
void make_set(int v){ | |
parent[v]=v; | |
} | |
int findset(int v){ | |
if(v == parent[v]) | |
return v; | |
return parent[v]=findset(parent[v]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment