src/test/java/edu/neu/coe/info6205/union_find/Alternative2.java
public int find(int p) {
        validate(p);
        int root = p;

        if(path_halving)
            root = doPathHalving(root);        
        else{                                  
            while (root != parent[root])
                root = parent[root];
            while (p != root) {
                int newp = parent[p];
                parent[p] = root;
                p = newp;
            }
        }
        return root;
    }
/**
     * Returns the component identifier for the component containing site {@code p}.
     *
     * @param p the integer representing one site
     * @return the component identifier for the component containing site {@code p}
     * @throws IllegalArgumentException unless {@code 0 <= p < n}
     */
Returns the component identifier for the component containing site  p.
@param p the integer representing one site
@return the component identifier for the component containing site  p
@throws IllegalArgumentException unless  0 <= p < n
Returns the component identifier for the component containing site p . @param p the integer representing one site @return the component identifier for the component containing site p @throws IllegalArgumentException unless 0 < = p < n
public int find(int p) {
        validate(p);
        int root = p;
        if(path_halving)
            root = doPathHalving(root);        
        else{                                  
            while (root != parent[root])
                root = parent[root];
            while (p != root) {
                int newp = parent[p];
                parent[p] = root;
                p = newp;
            }
        }
        return root;
    }
public int find ( int p ) { validate ( p ) ; int root = p ; if ( path_halving ) root = doPathHalving ( root ) ; else { while ( root != parent [ root ] ) root = parent [ root ] ; while ( p != root ) { int newp = parent [ p ] ; parent [ p ] = root ; p = newp ; } } return root ; }
Returns the component identifier for the component containing site {@code p}.
Returns the component identifier for the component containing site { @code p } .