union / find algorithms from Princeton's analysis of algorithms