Question: Consider the forest implementation of the disjoint-sets abstract data type, with an initial forest of n distinct elements (each one in a one-node tree). Let
Consider the forest implementation of the disjoint-sets abstract data type, with an initial forest of n distinct elements (each one in a one-node tree). Let be any sequence of k UNIONs followed by k 0 FINDs; so all UNIONs occur before the FINDs. Prove that the algorithm using Path Compression only (it does not use the Weighted-Union rule) executes in O(k + k 0 ) time, i.e., in time proportional to the length of , in the worst-case. Do not make assumptions on k or k 0 (for example, do not assume that k = n 1 or that k 0 k). As we did in class, assume that the parameters of each UNION are two set representatives, i.e., two tree roots (so there are no FINDs inside each UNION). Hint: To compute the cost of executing all the FINDs use an amortization-like charging scheme
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
