Equivalence class

xiaoxiao2021-03-05  23

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

转载请注明原文地址:https://www.9cbs.com/read-32242.html

New Post(0)