//LL Rotation
template <class T>
TreeNode<T>
BinarySearchTree<T>::_leftRotation(TreeNode<T> node)
{
TreeNode<T>* nd;
nd = node->_left;
node->_left = nd->_right;
nd->_right = node;
nd->_height = calheight(nd);
node->_height = calheight(node);
return nd;
/*
*
*Codes from tutorialshorizon
*copyrights to -
https://algorithms.tutorialhorizon.com/avl-tree-insertion/
*
//*/
//TreeNode<T>* nd = node->_right;
//TreeNode<T>* T2 = nd->_left;
//nd->_left = node;
//node->_right = T2;
//nd->_height = calheight(nd);
//node->_height = calheight(node);
//return nd;
}
//RR Rotation
template <class T>
TreeNode<T>
BinarySearchTree<T>::_rightRotation(TreeNode<T> node)
{
TreeNode<T>* nd;
nd = node->_right;
node->_right = nd->_left;
nd->_left = node;
nd->_height = calheight(nd);
node->_height = calheight(node);
return nd;
/*
*
*Codes from tutorialshorizon
*copyrights to -
https://algorithms.tutorialhorizon.com/avl-tree-insertion/
*
*
//
TreeNode<T>* nd = node->_left;
TreeNode<T>* T2 = nd->_right;
nd->_right = node;
node->_left = T2;
nd->_height = calheight(nd);
node->_height = calheight(node);
return nd;*/
}
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by BearTeddy