next up previous
Next: Up: Previous:

Sortof BST Delete

1.
Use of sentinel nil(T) for NIL leaves
2.
Call to RB-Delete-Fixup

   RB-Delete(R,z)                ; return deleted node
      if left(z) = nil(T) or right(z) = nil(T)
      then d = z
      else d = Successor(z)
      if left(d) <> nil(T)
      then c = left(d)
      else c = right(d)
      parent(c) = parent(d)      ; no test for NIL with sentinel
      if parent(d) = nil(T)
      then root(T) = c
      else if d = left(parent(d))
           then left(parent(d))) = c
           else right(parent(d))) = c
      if d <> z
      then key(z) = key(d)
      if color(d) = Black
      then RB-Delete-Fixup(T,c)  ; c is now "Double-Black"
      return d


next up previous
Next: Up: Previous: