Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void make_set (int v) {
- parent[v] = v;
- }
- int find_set (int v) {
- if (v == parent[v])
- return v;
- return parent[v] = find_set (parent[v]);
- }
- void union_sets (int a, int b) {
- a = find_set (a);
- b = find_set (b);
- if (a != b)
- parent[b] = a;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement