Question
The following question will explore the possibility of taking two red-black trees with a special property and merging them together into one red- black tree.
The following question will explore the possibility of taking two red-black trees with a special property and merging them together into one red- black tree.
(a) Explain how we can store the black height, bh(x), of an rb-tree in the root x. Explain how we can maintain this extra field at no extra cost.
(b) Given two red black trees, T1 and T2 such that every key in T1 is less than every key in T2, give an algorithm to merge T1 and T2 into one tree. Make sure you also explain your time complexity in addition to the algorithm. You should first give an overview of your algorithm and then pseudocode that explains more completely.
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