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. You do not need to implement the in-order traversal or the height. We will call in-order traversal to check your output and 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; Sample Input 1 10 2 15 Sample Output 1 15 20 Sample Input 2: 10520 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
