CS 112
Hw 9
Due Monday 20 Nov. 2000, by midnight
List implementation of Stacks
Implement a Stack abstract data type using a linked list (instead
of an array). Then recompile the arithmetic expressions homework
(Hw 6) using this new stack. Part of this homework was started
during the lab this week. Here are all the steps.
- Copy the IntStack.h, IntStack.cpp, makefile and test
driver from your Hw5 or from here.
- Modify what is necessary: the private part in the header file,
the implementation file, and maybe the test driver
(no need to test the stack becoming full, although you can if you wish so.)
- Your stack should now use a list instead of an array,
so make sure you include the IntList class (from previous
homework) in your compilation (careful with the Makefile!).
As discussed in class today, you
do not need the full power of lists, just InsertFirst and
DeleteFirst. You will have to modify them (even if they worked
fine for Hw 8) to delete unused nodes when you call the
Delete or DeleteFirst functions on a list.
- Then, after testing the stack and making sure it works
correctly (e.g. by using the same testdriver you had for Hw5),
copy your ArithExpr class files and recompile everything
using the new stack.
References and how to proceed
- You can use the textbook, Chapters 3 and 5, as a reference.
- Create a directory Hw9.
Copy the IntStack.h, IntStack.cpp, makefile and test driver from
Hw5. Modify what is necessary: the private part in the header file,
the implementation file, and maybe the test driver (no need to test the
stack becoming full, although you can if you wish so.)
- Copy the IntList.cpp, IntList.h from your Hw8. Modify the
Makefile to compile it, too. Modify the Delete functions and test
them.
- Test the new stack with the same testdriver you used for the
stack implemented as an array.
- Copy the ArithExp files, modify the Makefile, recompile with
the new Stack.
- Prepare the typescript, then submit ALL the files needed to
make your program compile and execute (including data file).
The purpose of this homework is to illustrate code reuse and
the advantages of an object-oriented design of a program, whereas changing
the implementation of a class should not affect the implementation of the
programs which used objects/methods from that class.
To submit
Submit in Hw9 all the files: sources, Makefile, a
typescript and a data file with your test data.
See below for naming conventions.
Naming conventions and files to submit (in Lab18):
- List of integers: IntList.cpp, IntList.h
- Stack of integers: IntStack.cpp, IntStack.h
- Arithmetic expression: ArithExp.h and ArithExp.cpp
- Test driver: testArithExp.cpp
- Makefile
- Data file: data
- typescript
Submit in Hw9, by Monday night (Nov. 20, midnight),
all the files that are necessary for
compiling, executing and proving the correctness of your code:
header and implementation
files, testdriver, makefile and a typescript.
Ileana Streinu