(Latest Revision: 09/02/2000)
The Strange Stack: Implementing a Data Structure
RATIONALE:
One of the main points of this exercise is to impress upon you
that abstract data structures need not be implemented in a way
that conforms at all to preconceived notions. Often
programmers need to find new and creative ways to implement the
data structures they want to use.
THE ASSIGNMENT:
Implement a stack of letters in an unusual way: using just a
single unsigned long int to contain the stack elements. In
other words one integer variable will be used as a stack
that can store several letters.
WHAT I GIVE YOU:
I am giving you a main program called
driver.cpp, a header file called
stack.h, and a form for a stack.cpp file called
stack.cpp.form.
Make copies of those files and look them over carefully. By
reading stack.h, you will learn the specifications for the
stack operations that I want you to implement. The file
driver.cpp is just that: a driver program you can use to test
your implementation of the stack.
WHAT YOU GIVE ME:
After you understand stack.h, make a copy of stack.cpp.form and
name it stack.cpp. Fill it in with your name, user name, and
implementations of all the functions in stack.h. Look at pages
263-264 in your textbook for an idea of the format you
need to use. Keep in mind, however, that the source code you
must create will be radically different from the code you see
in the book.
Create a comprehensive test plan for making sure that all the
functions you have implemented work according to
specifications. E-mail me a copy of the completed stack.cpp
file plus a script showing that you used the driver to run all
your tests successfully. You may look at my directions on
how to make a script. You may also check out these sample
scripts:
top-level run,
level-two run, and
level-three run.
ADDITIONAL SPECIFICATIONS:
Before you do any assignment for me, you need to read the
programming assignment rules. This document contains my
general rules regarding form, and style. The document also
describes my grading criteria. (Note: on this assignment you
are not required to write any function header comments -- I
have provided you with all of them.)
Together, the files stack.h and stack.cpp must implement a
stack class. You are not allowed to change anything in stack.h
or in driver.cpp. In fact when I test your version of the
stack.cpp file, I will just compile it together with my
(original) copies of driver.cpp and stack.h. Therefore, you
must write stack.cpp so it works correctly in conjunction with
the original stack.h and driver.cpp. You must implement the
stack operations exactly as they are specified in the header
comments in stack.h.
The stack class must use the private variable "data" defined in
stack.h for storage of all stack elements. The variable "data"
is a single unsigned long int. The element set for the stack
class must be the set of lower case letters, 'a' through 'z.'
When your program is compiled on the Sun Ultra's using the g++
compiler, a member of your stack class must have a capacity of
at least six lower case letters. You can achieve this easily
if you take advantage of the fact that you only need 26
different "codes" for stack elements.
HELP:
Figuring out the details of this implementation can be tricky.
Come to class to get helpful information.
WHAT TO TURN IN:
You will be sending me two e-mail messages. Please follow
these rules:
- Always send me e-mail as plain text in the main
message body: never send me attachments or specially
formatted or encoded documents.
- I will tell you what subject line to use with each
message, and I need you to use exactly the
subject lines I give you. (I get hundreds of e-mail
messages at a time and your subject line allows me to
sort messages.)
Send the following two items to me by e-mail before midnight on
the due date:
- A copy of your stack.cpp file. Use this subject line:
CS3100,prog1,stack.cpp
- A copy of your script file. Use this subject line:
CS3100,prog1,script
Note that there are no spaces in the subject lines given. It
is important that you do not insert any spaces. My e-mail
address is:
john@ishi.csustan.edu.
DUE DATES:
For due dates, see
the class schedule.