Mastery exams are solo projects
testing deque programs
The program exerciser.cc was used
to test aspects of the deque implementation. A template file
exertemplate.cc was used to
generate instantiations of the deque class.
In addition, you should implement a destructor, assignment operator, and
copy constructor.
Perhaps the easiest way to meet the requirements for O(1) append and
prepend and expected O(1) access is to use a directory array
of pointers to
nodes. Each node contains an array of (say 20) elements. Initially the
middle node of the directory array is the only non-NULL pointer. To
prepend you can add a new node before the middle directory node. A node is
added after the middle directory node when the 20-element middle node is
full. You'll only need to grow the directory array when all its nodes
are allocated.
You may find it easier to implement a non-templated version of
this class first (e.g., for ints or strings) and then change the
implementation to be templated.
Templated Deques
You are to implement a templated class for double-ended queues, also
called deques. You must implement the following operations for
your deque class (as member functions).
Implementation Details
You cannot use any classes in your implementation, the deque must be
implemented using only built-in types (e.g., no vector class, no list
class). You should feel free to borrow/steal code from the vector and
list classes (on acpub see ~ola/courses/lib on cs machines
see /usr/project/courses/cps008/lib.)
Inherited Interface
Your class must be implemented by inheriting from the abstract base
class ADeque declared below and accessible from
~ola/cps108/deque/adeque.h
Submission
Submit as shown below. You must submit .h and .cc files for your
dequeue class. You must inherit from ADeque to facilitate
our test programs. You should also submit your own test program
testdeq.cc along
with an explanation (in your README) of what your test program does and
how well you think it tests the correctness of
your implementation. In your README you should also
include a profile analysis (obtained using gprof) of a program
testperf.cc that
stresses the performance of your dequeue class. You should submit this
test program too. Note that there will be two test programs: one to
test performance and one to test correctness of the deque class
functions. Your makefile should be able to make both.
submit108 mastery dequeue.h dequeue.cc testdeq.cc testperf.cc README Makefile ...
Grading
This assignment is worth 50 points awarded as follows.
Behavior | Points |
---|---|
Works Correctly (performance irrelevant) | 10 |
Meets Performance Specs | 10 |
Style/Coding standards | 10 |
Test Programs | 10 |
README, Writeup | 10 |
For extra credit, your deqeue class should handle it's own memory allocation, e.g., nodes that are deleted should be kept on a per-class (e.g., static) freelist and these nodes should be used when allocating new nodes. This can earn an aditional 10 points.