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

Sorted List

      Find first object in L
      whose key is greater than key(x).
      Put x just before

      if head(L) = NIL  or  key(head(L)) >= key(x)
      then next(x) = head(L)
           head(L) = x
      else y = head(L)
           while next(y) <> NIL  and  key(next(y)) < key(x)
              y = next(y)
           next(x) = next(y)
           next(y) = x


Copyright © 1998 The University of Texas at Arlington