Question: Consider two binary search trees ( BSTs ) named T 1 and T 2 , rooted at Root 1 and Root 2 , respectively. Both
Consider two binary search trees BSTs named T and T rooted at Root and Root respectively. Both T and T are AVL AdelsonVelskyLandis trees with M and N nodes, respectively. Every node of T and T has three fields: value, leftlink and rightlink. T and T have no common value. Define merging of a BST T with a BST T as a process that combines the two BSTs to form a single BST by attaching the root of T to a left or rightlink of T that is free. Thus, the merge operation excludes one by one insertion of the nodes of one BST into the other. a Create two AVL trees TA with integer values and TB with integer values such that TB cannot be merged with TA as per the above definition. Note that TA and TB must not have any common value. b Design an algorithm that takes two AVL trees T and T as input and merges T with T if possible, otherwise reports an error. Explain your algorithm. Deduce the time complexity of your algorithm, and also find the maximum possible height of the merged tree in terms of the heights of T and T
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
