Weighted_Union.cpp
//     Root calculation using path compression O(logN)
Root calculation using path compression O(logN)
Root calculation using path compression O ( logN )
int root_using_path_compression(int arr[],int A)
{
 int i=A;
 while(i!=arr[i])
 {
  arr[i]=arr[arr[i]];
  i=arr[i];
 }
 return i;
}
int root_using_path_compression ( int arr [ ] , int A ) { int i = A ; while ( i != arr [ i ] ) { arr [ i ] = arr [ arr [ i ] ] ; i = arr [ i ] ; } return i ; }
Root calculation using path compression O(logN)
Root calculation using path compression O ( logN )