Convert this c++ code to c language #include using namespace std; //FIND(X) int find(int X, vector& parent) { if (parent[X] == X) return X; return find(parent[X], parent); } //UNION(X,Y) void...


Convert this c++ code to c language



#include using namespace std; //FIND(X) int find(int X, vector& parent) { if (parent[X] == X) return X; return find(parent[X], parent); } //UNION(X,Y) void UNION(int X, int Y, vector& parent) { parent[Y] = X; } int main() { int n, m; cout < "enter="" number="" of="" edges\n";="" cin="">> n; cout < "enter="" number="" of="" nodes\n";="" cin="">> m; //edges list //each edge is a vector [u,v] vector<> > edges(n); for (int i = 0; i < n;="" i++)="" {="" int="" u,="" v;="" cout="">< "info="" for="" edge="" "="">< i="" +="" 1="">< endl;="" cout="">< "enter="" source="" node="" u:="" ";="" cin="">> u; cout < "enter="" destination="" node="" v:="" ";="" cin="">> v; edges[i] = vector{ u, v }; } vector parent(m + 1); for (int i = 1; i <= m;="" i++)="" parent[i]="i;" for="" (auto="" edge="" :="" edges)="" {="" find="" set="" name="" for="" source="" node,="" u="" int="" x="find(edge[0]," parent);=""><><><= m;="" i++)="" if="" (parent[i]="=" i)="" count++;="" cout="">< "number="" of="" disjoint="" set="" is="" :"="">< count="">< endl;="" cout="">< "printing="" the="" parent="" array="" now:\n";="" for="" (int="" i="1;" i=""><= m;="" i++)="" cout="">< parent[i]="">< "="" ";="" cout="">< endl;="" return="" 0;="">

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here