Implemented second task (Quick Union and Weighted Quick Union Algorithms)