
(Last Revision: 10/27/96)

//////////////////////////////////////////////////
CS 2500 PROGRAMMING ASSIGNMENT #03

IMPLEMENTING A DEQUE USING 
A DOUBLY-LINKED LIST STRUCTURE.
//////////////////////////////////////////////////

THE ASSIGNMENT

You will be implementing a data structure called a "deque".  A deque is
like a cross between a stack and a queue.  A deque has a front and a
rear.  You can insert an element at either the front or rear, and you can
take an element out from either the front or rear.

To implement the deque, you will be writing the code for the deque
operations: CreateDeque, ClearDeque, EmptyDeque, FullDeque, InDequeFront,
InDequeRear, OutDequeFront, OutDequeRear, and PrintDeque.  

Normally implementing a Pascal data structure also requires designing the
TYPE declarations for the data.  I've furnished you with the declarations
that you must use in the file called dequeTypes.h.  In file deque.p you
will find specifications for what each of the operations must do.  Each
operation is specified by giving a complete Pascal procedure or function
statement, followed by a subprogram header which tells what the operation
is supposed to do.

You must finish each operation in deque.p so that it uses the exact same
procedure or function statement I gave, and so it follows the other
specifications given in the header.  Also, you must use the Pascal TYPE
declarations in dequeTypes.h.

Another wrinkle is being added to this assignment.  We are going to
create our deque data structures in the form of a separate module.  This
idea is something like the Turbo Pascal units you may have been reading
about in our textbook.  Our pc compiler on the Suns has a similar
capability.  It is pretty "clunky" but it makes a certain amount of
modularity and information hiding possible.  

You will start this assignment by making copies of the files dequeTypes.h,
dequeOps.h, deque.p, and driver.p.  You can get all of those files from
the Gopher space in the Asg3 directory.

Basically your job is to do two things:

1.  add to a copy of deque.p the code that completes all the deque
    operations found there.  Also you must add any comments that are
    needed

2.  add to the shell driver file driver.p the necessary code to make it
    read commands to operate the deque from standard input, and write the
    results to standard output.  Of course, this file also needs comments.

The code that implements the deque is all contained in the files deque.p
and dequeTypes.h.  The file dequeOps.h and the "include" directives you
will find in the driver.p program are the "glue" that joins together the
driver.p program with the files that implement the deque.  You should not
make any changes to dequeTypes.h or dequeOps.h, but you need to be aware
of what is in both of them, especially dequeTypes.h

As you write the driver program, you will be able to program calls to the
deque operations.  Those calls will work when the program runs, even
though the deque operations are not actually defined in driver.p.  Do not
place any code in driver.p that references the deque in any other way
*except* to make calls to the deque operations.  This is very important
in order to maintain modularity and information hiding.

When you compile the program, do it like this:

pc deque.p driver.p

or 

pc -o driver deque.p driver.p


PROGRAM INPUT AND OUTPUT

The files sample.in and sample.out contain the samples of the type of
input the driver must process, and the corresponding output that is
produced.  The input consists of very simple commands which tell the
driver to perform operations on the deque.  There is a stop command that
tells the program when to quit.  Assume that the input file will be
completely logical.  For example, in any input that contains more than
just the stop command, the create command will always come first.  Also,
no command will attempt to remove somthing from the deque if it is empty.

IMPLEMENTATION DETAILS

For technical reasons that we will be discussing in class, it is
inconvenient to implement a deque with a singly-linked list.  Therefore
we are going to implement our deque with a doubly-linked list.  We will
be discussing some of the details of the processing required for doing
insertions and deletions.

HOW TO TURN IN MULTI-FILE SOURCE CODE

When your source code is all ready to turn in by e-mail, do the following
commands:

% shar deque.p driver.p > mysource
% mail -v -s "CS25 p3 L2 source" john@ishi < mysource

The shar command "packs up" deque.p and driver.p into one shell archive
that I can "unpack" by doing the command 

% /bin/sh mysource

The mail command above sends the archive to me.  This method gives us a
convenient way of e-mailing a program that consists of many files as one
message.  Notice that I am *not* asking that you send me your copies of
dequeOps.h and dequeTypes.h.  You aren't supposed to make any changes to
those files anyway, so it is best if you not send the files. I will use
my own copies of dequeOps.h and dequeTypes.h to compile with your source
code.

=================================================================
Due DATES:

October 30 (* note: change *)

Turn in a program #3 Second Level program, plus whatever extra
programming is needed to have the CreateDeque, InDequeFront, and
PrintDeque operations working.  You need to have those operations working
because I need to be able to test the program by telling it to insert
some numbers in the front of the deque, and then tell the program to
print the contents of the deque so I can see if the insertions worked
properly.  

(Don't forget to turn in both source file and test script via e-mail by
midnight)
	     
November 04 (* note: change *)

Program #3 final-level program DUE.  

(Don't forget to turn in both source file and test script via e-mail by
midnight)

===========================================================================
As usual, I want you to be familiar with the class documents entitled:

programAssignmentRules,
sampleProgramSubmission-level01,
sampleProgramSubmission-level02,
sampleProgramSubmission-level03,
howToMakeTestScript-level01, 
sampleTestScript-level01,
sampleTestScript-level02, and
sampleTestScript-level03

before beginning to do this programming assignment.  You will find the
documents under "CourseDocuments" in the class directory.
===========================================================================
