Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. private static AVLTreeNode rotateWithLeft(AVLTreeNode k2 )
  2.         {
  3.             AVLTreeNode k1 = k2.left;
  4.             k2.left = k1.right;
  5.             k1.right = k2;
  6.             k2.height = Math.max( k2.left.height, k2.right.height ) + 1;
  7.             k1.height = Math.max( k1.left.height, k2.height ) + 1;
  8.             return k1;
  9.         }
  10.  
  11.         private static AVLTreeNode rotateWithRight( AVLTreeNode k1 )
  12.         {
  13.             AVLTreeNode k2 = k1.right;
  14.             k1.right = k2.left;
  15.             k2.left = k1;
  16.             k1.height = Math.max( k1.left.height, k1.right.height ) + 1;
  17.             k2.height = Math.max( k2.right.height, k1.height ) + 1;
  18.             return k2;
  19.         }
  20.  
  21.         private static AVLTreeNode doubleWithLeft( AVLTreeNode k3 )
  22.         {
  23.             k3.left = rotateWithRight( k3.left );
  24.             return rotateWithLeft( k3 );
  25.         }
  26.  
  27.         private static AVLTreeNode doubleWithRight ( AVLTreeNode k1 )
  28.         {
  29.             k1.right = rotateWithLeft( k1.right );
  30.             return rotateWithRight( k1 );
  31.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement