previous | start | next

The rotateLeft Method

Here is the method:

  private static Node rotateLeft( Node p )
  {
    // p's right child becomes the new subtree root
    Node r = ?;
    p.right = ?;
    r.left = ?;

    // Adjust the heights if 'height' is stored in the nodes.


    return r;
  }

Note: The height method is a static method that just returns the height of
the node passed to it, but also handles the case if null is
passed. In the later case, height returns -1.
   


previous | start | next