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

Operations

   Min(L)
      m = head(L)
      x = head(L)
      while x <> NIL
         if key(x) < key(m)
         them m = x
         x = next(x)
      return m

Max(L) is similar

   Successor(L,x)
      s = NIL
      y = head(L)
      while y <> NIL
         if key(y) > key(x)
         then if s <> NIL
              then if key(y) < key(s)
                   then s = y
              else s = y
         y = next(y)
      return s

Pred(L,x) is similar



Copyright © 1998 The University of Texas at Arlington