1. Engineering
  2. Computer Science
  3. 3 15 pointscompleteness implementing avl rotation and insertion suppose youve...

Question: 3 15 pointscompleteness implementing avl rotation and insertion suppose youve...

Question details

3. (15 points-Completeness) Implementing AVL rotation and insertion: Suppose youve been given the following code: class AVINode public: AVINodeleft; AVİNode * right ;. AVLNode parent: int data; int height; * Height of subtree rooted here. A single node has height 1* AVLNode (const int d) : data (d), height ( 1 ) { left -right-parent= nul!ptr; } private: void adjustHeight Adjust the height of this node to reflect the height of the subtrees, which are assumed correct. Implementation given below / /* Assuming the heights of the children are set correctly, adjust the height of the subtree rooted at this node */ void AVINode: :adjustHeight ) int left, right 0; if (this-left!- nullptr) left - this->left->height; if (this->right != nullptr) right- this->right-height; height- max (left, right) 1;
media%2Fe91%2Fe917ad19-5af8-4a63-ab88-80
) Implement rotateLeft in C++ * Rotate left top. The node top->parent (if present) should remain an ancestor of all of its descendants and tops location in the tree should be replaced by top->right. void AVLTree: :rotateLeft (AVLNode top) f
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution