Union by rank - Time complexity

What is the time complexity of DSU’s find and union by rank function?

Is it O(logn) or O(1)? As during construction there is a logn factor involved?

hello @deep4013

It will be log(n). becuase for union first we need to find the parents

Okay got it , thanks.

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.