Guest User

Untitled

a guest
May 4th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. //rotating methods to balance the tree accordingly
  2. private void rotateLeft(ref Node<T> tree)
  3. {
  4. if (tree.Right.BalanceFactor > 0)
  5. {
  6. rotateRight(ref tree.Right);
  7. }
  8. Node<T> newRoot = tree.Right;
  9. tree.Right = tree.Right.Left;
  10. newRoot.Left = tree;
  11. tree = newRoot;
  12. }
  13.  
  14. private void rotateRight(ref Node<T> tree)
  15. {
  16. Node<T> newRoot = tree.Left;
  17. tree.Left = tree.Left.Right;
  18. newRoot.Right = tree;
  19. tree = newRoot;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment