Untitled
unknown
plain_text
4 years ago
729 B
7
Indexable
private void rotateLeft(ref Node<T> tree)
{
if (tree.Right.BalanceFactor > 0) //double rotate
rotateRight(ref tree.Right);
Node<T> oldRoot = tree;
Node<T> newRoot = tree;
newRoot.Left = oldRoot;
oldRoot.Right = newRoot;
newRoot.Left = oldRoot.Right;
}
private void rotateRight(ref Node<T> tree)
{
if (tree.Left.BalanceFactor < 0)
rotateLeft(ref tree.Left);
Node<T> oldRoot = tree;
Node<T> newRoot = tree;
newRoot.Right = oldRoot;
oldRoot.Left = newRoot;
newRoot.Right = oldRoot.Left;
}Editor is loading...