WeightedQuickUnion UF implementation