Add unionFind.c to misc folder

This commit is contained in:
Sesar Hersisson 2019-10-01 12:37:01 +00:00
parent 90f9c0a39b
commit 9b72741a31
1 changed files with 22 additions and 0 deletions

22
misc/unionFind.c Normal file
View File

@ -0,0 +1,22 @@
int p[1000000];
int find(int x)
{
if (p[x] == x)
{
return x;
}
else
{
p[x] = find(p[x]);
return p[x];
}
}
// Call to function join(int x, int y) to join PARAM x and y
void join(int x, int y)
{
p[find(x)] = find(y);
}
int main() {
return 0;
}