Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2. The uptrees used to represent sets in the union-find algorithm can be stored in two n-element arrays The up array stores the parent of
2. The uptrees used to represent sets in the union-find algorithm can be stored in two n-element arrays The up array stores the parent of each node (or-1 if it has no parent). The weight array stores the number of items in a set if the node is the representative node of a set (else the weight entry for the node does not matter and can be anything) The following shows a collection of sets containing the numbers 1 through 12, without the weight array filled in 1 101 9 11-1 weight 9 10 12 a) b) c) Draw a picture of the uptrees represented by the data in the up array shown above Fill in the weight array above so that all entries that need to be correct are correct. Suppose we did not keep the weight array updated as operations are performed. As you did in part (a), the algorithm could compute weights as needed. Would this asymptotically slow down find operations that use path compression? Suppose we did not keep the weight array updated as operations are performed. As you did in part (a), the algorithm could compute weights as needed. Would this asymptotically slow down union operations that use union-by-weight? Show the result of performing the operation find(4) with path compression by doing both of the following d) e) Redraw below any uptrees (from part (a)) that change as a result. Update the array representation as appropriate by drawing a single slash (V") through any numbers that change and writing the new number next to it
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started