implemented weighting in the quick union uf algorithm