next up previous
Next: Up: Previous:

Rotations

   Right-Rotate(T,y)
      x = left(y)           ; assume left(y) <> NIL
      left(y) = right(x)
      if right(x) <> NIL
      then parent(right(x)) = y
      parent(x) = parent(y)
      if parent(y) = NIL
      then root(T) = x
      else if y = left(parent(y))
           then left(parent(y)) = x
           else right(parent(y)) = x
      right(x) = y
      parent(y) = x


next up previous
Next: Up: Previous: