INT * E; Void Initialize (int N) {E = new int [n 1]; for (int i = 1; i <= n; i ) e (i) = i;} void union (int i, int J) {for (int K = 1; k <= n; k ) IF (e (k) == j) e (k) = i;} int Find (INT i) {RETURN E (i);}
Void main () {INT I, J; i = Find (a); j = find (b); if (i! = j) union (i, j);}
Ref: << Data Structure, Algorithm & Applications >> P117 ~ 121