next up previous
Next: Rotations Up: CSE 2320: Algorithms and Previous: Rotations

Rotations

   Left-Rotate(T,x)
      y = right(x)          ; assume right(x) <> NIL
      right(x) = left(y)
      if left(y) <> NIL
      then parent(left(y)) = x
      parent(y) = parent(x)
      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
      parent(x) = y



Copyright © 1998 The University of Texas at Arlington