You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Union replaces the set containing x and the set containing y with their union.
68
-
// Union uses Find to determine the roots of the trees containing x and y.
69
-
// If the roots are the same or one of the elements doesn't exist in the set,
70
-
// there is nothing more to do. and Union returns false
71
-
// Otherwise, the two sets get be merged. This is done by either setting
72
-
// the parent element of the element with the smaller size to the other parent
73
-
// and the return of the function in this case is true
67
+
// Union replaces the set containing x and the set containing y with their union. It first determines the roots of the sets containing x and y.
68
+
// If the roots are the same or one of the elements does not exist in the data structure, there is nothing more to do. Otherwise, the two sets get be merged.
69
+
//
70
+
// The root of the new set is the root of the set with bigger size. In case both sets have the same size, the root is the root of set y.
0 commit comments