implemented disjoint set forest with rank by union and path compression