Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Data structure (This question does not involve coding) Using a set of values fro

ID: 3915512 • Letter: D

Question

 Data structure  (This question does not involve coding) Using a set of values from 0 to 10, perform the following unions using union-by-size.  Show the result of each union.  When sizes are the same, make the second tree be a child of the first tree.       union(find(0),find(1))  // union the two roots, one from find(0) and one from find(1)     union(find(2),find(3))     union(find(4),find(5))     union(find(4),find(6))     union(find(7),find(8))     union(find(7),find(9))     union(find(7),find(10))     union(find(1),find(5))     union(find(3),find(9))     union(find(1),find(3)) Illustrate the array for the final forest of the previous problem (note that roots are not simply -1 when using union-by-size).       Similar to problem 1, but using union-by-height.       union(find(0),find(1))     union(find(2),find(3))     union(find(1),find(3))     union(find(4),find(5))     union(find(4),find(3))     union(find(6),find(7))     union(find(8),find(9))     union(find(9),find(10))     union(find(7),find(10))     union(find(10),find(5))  Illustrate the array for the final forest of the previous problem (note that roots are not simply -1 when using union-by-height). 

Explanation / Answer

Answer:

1)

1 is the parent of 0.

3 is the parent of 2.

4 and 5 are siblings.

6 is the parent of 4 and 5.

8 is the parent of 7.

7 and 9 are siblings.

10 is the son of 7.

6 is the son of 1.

3 is the parent of 8.

3 is the son of 1.

2)

a[]={1,0,3,6,2,8,4,5,7,9,10};

3)

1 is the parent of 0. 3 is the parent of 2. 1 is the parent of 3. 4 is the son of 5. 5 is the son of 3. 6 is the son of 7. 9 is the parent of 8. 10 is the parent of 9. 9 is the parent of 7. 10 is the son of 5

4)

a[]={1,0,3,2,5,4,10,9,7,8,6};