Question: Implementing a rotation with an ALV tree in C++, Here's the code I've come up with for the right rotate function, but somehow it is
Implementing a rotation with an ALV tree in C++,
Here's the code I've come up with for the right rotate function, but somehow it is wrong?
void right_single(Node *& tmp)
{
Node *& tmp2 = tmp->left->right;
tmp->left->right = tmp;
tmp = tmp->left;
tmp->right->left = tmp2;
}
Right Single Rotate node: Pointer Reference to node Arguments Return Type None Description Prforms a Right single rotate on a left heavy tree Pseudocode 1. 2. 3. 4. Assign a temporary variable to node's left's right child. Set nodes left's right to point to node. Point node to node's left Point nodes rights left to the temporary variable
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
