next up previous
Next: Up: Previous:

Rotations

   Left-Rotate(T,x)
      y = right(x)                    ; assume right(x) <> NIL
      right(x) = left(y)              ; move y's child over
      if left(y) <> NIL
      then parent(left(y)) = x
      parent(y) = parent(x)           ; move y up to x's position
      if parent(x) = NIL
      then root(T) = y
      else if x = left(parent(x))
           then left(parent(x)) = y
           else right(parent(x)) = y
      left(y) = x                     ; move x down
      parent(x) = y


next up previous
Next: Up: Previous: