Showing posts with label tree rotation. Show all posts
Showing posts with label tree rotation. Show all posts

Dec 24, 2008

Tree rotation

Tree rotation can be used to rebalance the tree, because the upon subtree decrease the height by one while the down subtree increase the height by one. The order of the tree will keep the same

Right rotation:
Tree* pivot=root->left;
root->left=Root->left->right;
pivot->right=root;
root=pivot;