Please read the prompt carefully : Use C++ Write three functions: Node* rotateLe
ID: 3904562 • Letter: P
Question
Please read the prompt carefully :
Use C++
Write three functions:
Node* rotateLeft(Node *node);
Node* rotateRight(Node *node);
Node* rotateLeftRight(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 left right rotation should be performed as a left rotation on node's left child, then a right 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 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, then call rotateLeftRight on the root of the tree. 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
2 0 1
Sample Output 1:
012
Sample Input 2:
6
6 7 2 1 4 3
Sample Output 2:
123467
Sample Input 3:
10
9 4 10 11 6 1 3 7 5 8
Sample Output 3:
134567891011
Explanation / Answer
Below are your functions
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.