(Latest Revision: Thu Apr 12 10:31:52 PDT 2001 )
CS 2500 Programming Assignment #4 ENHANCING THE LIST ADT DUE DATES: NOTE: all three phases must compile and run without errors. (When needed, please ask for help in class, during office hours, or make an appointment.) Phase 1. Turn in a copy of the shell with the header comments for the new operations filled in, plus a test script. DUE: Wednesday, Nov 12, 1997 Phase 2. Turn in a copy of the shell containing the complete test driver and stubs for the new operations, plus a test script. DUE: Wednesday, Nov 19, 1997 Phase 3. In three separate, labelled e-mail messages, turn in: a) a copy of the shell with the new operations filled in, b) a copy of your input file, and c) a script showing a run of the tests, with successful outcomes for all. DUE: Wednesday, Nov 26, 1997 Your assignment is to extend the (ordered) List ADT by adding the following operations to a copy of the shell program I have given you: Name Type Purpose ValueInList Function Determine whether there is an element with the specified Key value in List. MergeLists Procedure Merge the elements in List1 and List2 into a single list, NewList. SplitList Procedure Split the elements in MainList into two lists, List1 and List2, according to the key value of each element. All elements with keys less than SplitValue will be put into List1; all elements with keys greater than or equal to SplitValue will be put into List2. GetElement Procedure Return a copy of the element in the Nth position of the List. PrintList Procedure Print out the List elements in key order (from smallest to largest key). ReversePrint Procedure Print out the List elements in reverse key order (from largest to smallest key). The first part of the assignment is to write header comments for each operation, in the following format: Operation (parameter list) Function: Inputs: Preconditions: Outputs: Postconditions: These header comments must specify what the operations do. Put the header comments into appropriate locations at the end of the set of list operations in your copy of the shell program. Next implement the operations, by adding the appropriate Function and Procedures to the shell. Create a test plan describing the test cases needed for each operation. Part of your grade will be determined by the completeness of the test plan. Fill in the main program so that it is a "test driver". In other words fill it in with the code required to carry out the tests that you planned. Write the main program so it reads from standard input and writes to standard output. You can prepare the list of strings you want the program to read in advance by putting the strings in a file, one string per line. Then you can run the test driver by typing a.out < inFileName > outFileName where "inFileName" stands for whatever the name is of your file of inputs, and outFileName is the name you want to give to the set of outputs you get for this run of the program. When your program writes its output, it must print lots of labels and comments so that it will be easy for the user of the program to understand what each test did, and what the results were. Typically this means there will be a series of tests. Before each test is performed, the program writes a little message identifying which operation is going to be tested, and what the inputs are going to be. Then the test is performed, and the program prints out a message showing what the result of the operation was. The user of the program should be able to look at the inputs and outputs, and determine for himself whether the test succeeded. The new list operations that you write are allowed to make calls to any of the list operations that already exist. Generally, it is poor form and style when list operations make calls to string operations, or vice-versa. However, in this program PrintList and ReversePrint are allowed to make calls to PrintString. ValueInList, MergeLists, and SplitList are also allowed to make calls to Compare. Your test driver is allowed to call any of the functions and procedures in the shell.