public static void main( String [ ] args )
 {
     int NumElements = 128;
     int NumInSameSet = 16;

     DisjointSets ds = new DisjointSets( NumElements );
     int set1, set2;

     for( int k = 1; k < NumInSameSet; k *= 2 )
     {
         for( int j = 0; j + k < NumElements; j += 2 * k )
         {
             set1 = ds.find( j );
             set2 = ds.find( j + k );
             ds.union( set1, set2 );
         }
     }

     for( int i = 0; i < NumElements; i++ )
     {
         System.out.print( ds.find( i )+ "*" );
         if( i % NumInSameSet == NumInSameSet - 1 )
             System.out.println( );
     }
     System.out.println( );
 }