Disjoint set UNION by RANK and Path Compression