Doubt in the video

sir at 11.32 min in the 56th line, I think that we need not check here if s1 and s2 are equal or not. In the union funtion that is going to be checked again so I think it is not needed

in union function we check if(s1!=s2)
because if both are equal and let say 1
then parent[1]=1 will be wrong
and now after this we can’t find leader of set by this condition
if(parent[i]==-1)

and also union doesn’t return us whether both set have same parent or not

that’s why we have to check that in contain cycle function also

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.