Question: Write three functions: Node* rotateLeft (Node node); Node* rotateRight (Node node); Node* rotateRightLeft (Node *node) These functions will take a node at which point you



Write three functions: Node* rotateLeft (Node node); Node* rotateRight (Node node); Node* rotateRightLeft (Node *node) These functions will take a node at which point you should perform the respective rotations for the balanced tree and return the new root. The right left rotation should be performed as a right rotation on node's right child, then a left rotation on node. The first input in test cases is the number of nodes. The second input is nodes of a tree which are inserted into a binary search tree that order. You don't need to implement insert. You have access to the root of the constructed Binary Search Tree We will create the tree for you, then call rotateRightLeft on the root of the tree. We will call in-order traversal to check your output and height. You do not need to implement the in-order traversal or the height. The output is an in-order traversal of the tree after the rotation and the height of the final tree. We have defined the following C++ Node class for you. The name serves as the value. class Node ( public: std::string name; Node * left = NULL; Node* right NULL; h; Sample Input 1: 10 20 15 Sample Output 1 10 15 20 Sample Input 2: 10 5 20 15 16 21 Sample Output 2 5 10 15 16 20 21
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
