Data Structures/Disjoint Set (Union Find).cpp
// Find the root of a node
Find the root of a node
Find the root of a node
int root(int x)
{
    if( uf[x].p != x )
        uf[x].p = root( uf[x].p );
    return uf[x].p;
}
int root ( int x ) { if ( uf [ x ] . p != x ) uf [ x ] . p = root ( uf [ x ] . p ) ; return uf [ x ] . p ; }
Find the root of a node
Find the root of a node
// Path compression