[java5] ab

Viewer

  1. Node leftRotate(Node x) {
  2.         Node y = x.right;
  3.         Node T2 = y.left;
  4.  
  5.         // Perform rotation
  6.         y.left = x;
  7.         x.right = T2;
  8.  
  9.         // Update heights
  10.         x.height = max(height(x.left), height(x.right)) + 1;
  11.         y.height = max(height(y.left), height(y.right)) + 1;
  12.  
  13.         // Return new root
  14.         return y;
  15.     }

Editor

You can edit this paste and save as new:


File Description
  • ab
  • Paste Code
  • 08 Apr-2020
  • 363 Bytes
You can Share it: