next up previous
Next: Successor(n) Up: CSE 2320: Algorithms and Previous: Searching

Analysis

Could write this code iteratively:

   if k < key(n)
   then n = left(n)
   else n = right(n)
   LOOP



   Min(n)     ; leftmost leaf of tree rooted at n
      while left(n) <> NIL
         n = left(n)
      return n
Min is



   Max(n)     ; rightmost leaf of tree rooted at n
      while right(n) <> NIL
         n = right(n)
      return n
Max is



Copyright © 1998 The University of Texas at Arlington