Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. private void Balance_Tree(Node current)
  2. {
  3. Node P;
  4. if (Balance_Factor(current) == 2)//left column
  5. {
  6. P = current.left;
  7. if (Balance_Factor(P) == -1)
  8. {
  9. RotateLeftRight(P);//left right case
  10. }
  11. else
  12. {
  13. RotateLeftLeft(current);//left left case
  14. }
  15. }
  16. if (Balance_Factor(current.left) == -2)//right column
  17. {
  18. P = current.right;
  19. if (Balance_Factor(P) == 1)
  20. {
  21. RotateRightLeft(P);//right left case
  22. }
  23. else
  24. {
  25. RotateLeftLeft(current);//right right case
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement