this code is giving wrong output for input in the code plz tell the reason why and make the correction in code & provide the corrected code as well…
it gives wrong ans for 2 and 3 it shows size of 3 as 1 only whereas it should be 2 as it is superparent of 2 as well…
Pairing problem graphs
plz reply as early as possible…
why is no one responding to this doubt…plz reply…
also tell the time complexity of the code …
@S19LPPP0202
you did a typing mistake at line 53. It should not be cin>>x,y
Also the time complexity for this is same as that of Disjoint Set for Connected Components. i.e. O(N).
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.