Computer Science 269
Introduction to Data Structures
Fall 2000
Assignment 1 Due September 7, 2000
Write a program which implements a sorted list of float values.
The program must contain the complete definition of sorted list
and a driver program to test the usage of a list.
Each cell of the list must contain a float value, together with a link
to the next cell, or a null link in the last cell.
The type must have the following methods:
-
A method which is a boolean function to test if the list is empty.
-
A method to print all the elements in the list.
-
A method to insert an element in the list, giving its value.
The list must remain sorted after inserting.
-
A method to delete an element, having as parameter the index of the
element in the list which is to be deleted. The index of a list node
is its position in the list. Thus, the first cell has index 1, the
next cell has index 2, and so forth.
Do not store the index in the cell.
-
A method to delete an element having as parameter the value of the
element in the list which is to be deleted.
The driver program (used to test your data structure) must be menu-driven.
The list will be initialized as empty automatically at the beginning of
the program.
The user will be asked to pick from a list of options, which must include:
-
Insert an element. The program will prompt the user for a value.
Duplicate elements can be inserted.
-
Test if the list is empty.
-
Report the length of the list.
-
Delete an element by value. The program will prompt the user for a value.
If there is more than one cell with that value, only the first will be
deleted.
The program will given an error message if that value is not present, but
will not halt.
-
Delete an element by index. The program will prompt the user for an index.
The program will given an error message if that index is not valid, but
-
Print all elements in the list in order.
You must
submit the program by email
to siona@cs.unlv.edu,
indicating the program name in the subject of the message. The program
will be checked for compilation errors and for a correct running. You
will receive results by email.
The deadline is September 5 at 5:30 PM.
No late homework will be accepted.