previous | start

The rotateLeft method

Here is the method:

  private Node rotateLeft( Node t )
  {
    // Rotate left with p's right child
    Node r = ?;
    t.right = ?;
    r.left = ?;

    // Adjust the heights since the nodes have been rotated.
    t.height = Math.max( height(p.left), height(p.right) ) + 1;
    r.height = Math.max( height(r.left), height(r.right) ) + 1;

    return r;
  }

Note: The height method 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