• + 1 comment

    Do we need below while loop in find(int p)? while(p !=root){ int newp = parent[p]; parent[p] = root; p = newp; } What is the purpose of this loop?