For the 566D - Restructuring Company
Basic Disjoint Set C++ implementation (w/o ranks) using int vector
class DisjointSet{ public:
vector<int> parent;
DisjointSet(int n): parent(n) { for(int i=0; i<n; i++) parent[i] = i; }
void join(int a, int b) { parent[find(b)] = find(a); }
int find(int a){ return a == parent[a] ? a : parent[a] = find(parent[a]); }
bool check(int a, int b){ return find(a) == find(b); }
};