Question: Let A and B be two given binary search trees storing the same n values. Note: it is enough to think of just the shapes
Let A and B be two given binary search trees storing the same n values. Note: it is enough to think of just the shapes of A and B. The values wont matter. (a) Outline an algorithm that transforms A into B only using rotations. Your algorithm should use O(n) rotations in the worst case. (b) Show that any algorithm that relies on rotations for such a transformation must use (n) rotations in the worst case. In other words, give an example of two trees that require a linear number of rotations, no matter what rotation-based algorithm is used. Explain why the bound holds.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
