next up previous
Up: APS105F Home

APS 105F - Computer Fundamentals

Assignment #8:  Linked List and Pointers

Fall 1997

(To be completed on November 5/6)

 

Objective:   To understand pointers and linked lists.

You are to write an interactive program that creates a linked list of data. The program should interact with the user so that the user can insert new items into the list, find a record in the list, and delete items from the list.

Your program must be modular. Each separate function described above (and perhaps others, as you see fit) should be implemented in a separate procedure, which the main program calls. Marks will be deducted for lack of good modular style.

1 The List

The linked list will contain the following items:

  1. A name (assume a single word, that is someone's last name).
  2. Their age.
  3. Their desired career occupation (a text description)

2 The Main Program

Your main program should create an empty list, ready for insertions. It should then prompt the user for a command, which can be one of five things:

  1. Insert - create a new record and put it into the list. Ask the user for the data to go in the record
  2. Find - ask the user for a name, and then find that name in the list and display the age and career.
  3. Delete - ask the user for a name, and then remove that person from the list.
  4. List - display the entire list.
  5. Quit - exit the program

Here is a sample interactive session:

	Linked List Maintainer of Name, Age and Career 

List has been initialized.

Commands are I (insert), F (find), D (delete), L (list), Q (quit)
Command?  I
  name: Chretien
  age:  62
  career:  ballet dancer
Inserted.

Command? I
  name: Manning
  age:  63
  career:  Concert Pianist
Inserted.

Command? I
  name: Charest
  age:  39
  career:  Prime Minister
Inserted.

Command? F
  name: Manning

Manning is 63 years old and wants to be a Concert Pianist

Command? D
  name: Charest

Charest deleted.

Command? D
  name: Gump

Gump is not in the linked list.

Command? L

Manning is 63 years old and wants to be a Concert Pianist
Chretien is 62 years old and wants to be a ballet dancer

Command? Q

Goodbye

3 The Procedures

You should use a separate procedure for each of the different commands given above.

Optional Section -- Sorted List

Make the program above maintain the list in sorted alphabetical order by the person's last name. Thus the insertion routine would have to insert any new item in the correct order.


next up previous
Up: APS105F Home

Paul Chow
Thu Oct 30 13:05:17 EST 1997