CS 117, Winter 1997

Assignment 8: Lists, due Monday 5/26/97

You may work with a partner for this assignment, but you might want to try it on your own in anticipation of doing the final project without a partner.

The program

Write a program that takes an arbitrary number of integers as input from the user, and prints the numbers out sorted from largest to smallest.

Here's the catch. To sort the numbers, I want you to do the following:

  1. Start with an empty linked list of nodes containing integer data.
  2. For each integer typed, insert a new node into the linked list in its proper position. That is, if you have the linked list
       
           head -> 10 -> 4 -> 3 -> nil
    
    and the next integer is a 6, you should end up with
       
           head -> 10 -> 6 -> 4 -> 3 -> nil.
    

    That's it. Start early, keep in touch, and have fun.



    Jeff Ondich, Department of Mathematics and Computer Science, Carleton College, Northfield, MN 55057
    (507) 646-4364, jondich@carleton.edu