next up previous
Next: Up: Previous:

Successor(n)

   Successor(n)
      if right(n) <> NIL
      then return Min(right(n))
      p = Parent(n)
      while p <> NIL and n = right(p)
         n = p
         p = Parent(p)
      return(p)

Successor is O(h)



   Predecessor(n)
      if left(n) <> NIL
      then return Max(left(n))
      p = Parent(n)
      while p <> NIL and n = left(p)
         n = p
         p = Parent(p)
      return(p)

Predecessor is O(h)


next up previous
Next: Up: Previous: