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
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