If we are having the BFS and DFS to find the cycle in the graph then why we use Union find and union rank

If we are having the BFS and DFS to find the cycle in the graph then why we use Union find and union rank and which should be always used , union find , union rank , bfs or dfs . and if it depends then on what :frowning: , too much confusion sir !!!

Your question is too confusing. Didn’t get you/
Please be a bit more clearer

I mean , what is the time complexity of Union Rank and Union find and what is its advantage over a simple BFS or DFS to find a cycle

Sorry for a delayed response. Just saw it now.
Time complexities for union and find is almost logn. DFS/BFS has O(n)
So they are much better.

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.