Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool avl_search_tree::avl_tree_node::rotate_left()
- {
- if (_right_child != NULL) {
- avl_tree_node *new_root = _right_child;
- if (_parent != NULL) {
- if (_parent->_left_child == this) {
- _parent->_left_child = new_root;
- } else {
- _parent->_right_child = new_root;
- }
- }
- new_root->_parent = _parent;
- _parent = new_root;
- _right_child = new_root->_left_child;
- new_root->_left_child = this;
- if (_right_child != NULL) {
- _right_child->_parent = this;
- }
- //update heights
- update_height();
- new_root->update_height();
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment