2. Consider the following program operating on disjoint sets over the domain {x1, x2, ..., x16}: 1 to 16 do MAKESET(xi) for for 1 to 15 by 2 do WUNION(xi, Xi+1) for i = 1 to 13 by 4 do WUNION (xi, Xi+2) WUNION(X1, X5) WUNION(X11, X13) WUNION (X1, X10) FINDSET(x2) FINDSET(X9) (a) Show the data structure that results after each step of the program (with the for loops considered single steps). Use both the tree and the array representation of disjoint sets. Assume (like we did in class) that if the sets containing x; and x; have the same size, then the operation WUNION(xi, x;) adds the set x; to the children of x;. (b) What is returned by the two calls to FINDSET? Explain.
2. Consider the following program operating on disjoint sets over the domain {x1, x2, ..., x16}: 1 to 16 do MAKESET(xi) for for 1 to 15 by 2 do WUNION(xi, Xi+1) for i = 1 to 13 by 4 do WUNION (xi, Xi+2) WUNION(X1, X5) WUNION(X11, X13) WUNION (X1, X10) FINDSET(x2) FINDSET(X9) (a) Show the data structure that results after each step of the program (with the for loops considered single steps). Use both the tree and the array representation of disjoint sets. Assume (like we did in class) that if the sets containing x; and x; have the same size, then the operation WUNION(xi, x;) adds the set x; to the children of x;. (b) What is returned by the two calls to FINDSET? Explain.
Related questions
Question
Question 2
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps