Data structures and algorithms for disjoint set union problems