Algoritms, part I - solution to first Union-Find exercises