Following the union find lecture on coursera