Question: Please I need help with this question. Thank you so much! 3. [Binary Search Trees, 60 points] Consider two binary search trees that contain the

Please I need help with this question. Thank you so much!

Please I need help with this question. Thank you so much! 3.

3. [Binary Search Trees, 60 points] Consider two binary search trees that contain the same set of unique keys, possibly in different orders. a. Devise and analyze an efficient algorithm that will transform any given binary search tree into any other binary search tree (with the same keys) using only ZIG and ZAG rotations The provided BST.h, and BST.cpp files contain a BST class, implementing a binary search tree, and a Rotation class, which stores a rotation. Implement a new derived class of BST, MyBST, which extends the binary search tree with a transform method, which implements your algorithm from part (a) You should also implement a main function, which receives two files, T1.txt and T2.txt (you may assume that these will be the names of the input files), containing one integer per line, to be inserted in order into two binary search trees. The transform method should receive the BSTs generated from T1 and T2, and return a vector of rotations required to transform T1 into T2, which is then printed out. You may not modify BST.h and BST.cpp, but you may add methods to MyBST.cpp as you see fit (and add a MyBST.h file) b. Assuming that the required rotations are a ZIG rotation on pivot-3, followed by a ZAG rotation on pivot-8, your output should be as follows ZIG on 3 ZAG on8 To get full credit your solution must work on any two binary search trees that contain exactly the same set of keys

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!