In this program realized Union Find algorithm for disjoint-set data structure.