Question: Write a function: Node* rotateRightLeft(Node *node); This function will take a node at which point you should perform the Right Left rotation for the unbalanced
Write a function:
Node* rotateRightLeft(Node *node);
This function will take a node at which point you should perform the Right Left rotation for the unbalanced tree and return the new root.
The first line of input in test cases is the number of nodes. The second line is nodes of a tree which are inserted in 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 and we will call in-order traversal to check your output.
The output is an in-order traversal of the tree after the rotation. 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:
3 5 7 6
Sample Output 1:
567
Sample Input 2:
4 5 7 6 8
Sample Output 2:
5678
code:
Node* rotateRightLeft(Node *node) { //your code here }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
