ShiningStarUSA
April 29th, 2008, 09:03 AM
this is is the input file :
Option = NoPathCompression
S = {a, b, c, d, e, f, g}
MakeUnionFind(S)
Union(a,d), Union(b,e), Union(c,f)
Union(c,g), Union(e,a)
Union(b,g)
and the output should be :
a, b, c, d, e, f, g
da, eb, fc, g
daeb, fcg
daefbcg
I am trying to implement MakeUnionFind(S)
S = {a, b, c, d, e, f, g}
this is one of the line that I am reading from a file. I have to create pointers for each of the member of S with the name of the member that points to itself in a function MakeUnionFind(S). The set s can contains numbers as well as strings. What I am trying to do here is to read the line in a buffer then trying to create an array from it and then planning to use that array to create pointers for each member of the set but I am not sure if my approach is right. Please help me, how can accomplish this task.
string line;
ifstream readfile ("C:\\test.txt");
getline (readfile,line);
Now I have to do split this input which is in buffer 'line' into array of strings where ',' is the delimeter. This is the part I am not able to do and I have to send these strings to the function one by one MakeUnionFind(S). In MakeUnionFind(S), we initialize a record for each element that belongs to S with a pointer than points to itself (or is defined as a NULL pointer) to indicate that v is in its own set.
Please let me know how can I accomplish this. Thanks for all your help in advance.
Option = NoPathCompression
S = {a, b, c, d, e, f, g}
MakeUnionFind(S)
Union(a,d), Union(b,e), Union(c,f)
Union(c,g), Union(e,a)
Union(b,g)
and the output should be :
a, b, c, d, e, f, g
da, eb, fc, g
daeb, fcg
daefbcg
I am trying to implement MakeUnionFind(S)
S = {a, b, c, d, e, f, g}
this is one of the line that I am reading from a file. I have to create pointers for each of the member of S with the name of the member that points to itself in a function MakeUnionFind(S). The set s can contains numbers as well as strings. What I am trying to do here is to read the line in a buffer then trying to create an array from it and then planning to use that array to create pointers for each member of the set but I am not sure if my approach is right. Please help me, how can accomplish this task.
string line;
ifstream readfile ("C:\\test.txt");
getline (readfile,line);
Now I have to do split this input which is in buffer 'line' into array of strings where ',' is the delimeter. This is the part I am not able to do and I have to send these strings to the function one by one MakeUnionFind(S). In MakeUnionFind(S), we initialize a record for each element that belongs to S with a pointer than points to itself (or is defined as a NULL pointer) to indicate that v is in its own set.
Please let me know how can I accomplish this. Thanks for all your help in advance.