CS 112
Homework 5

Due on Wednesday March 3, 2004, by 12:00 a.m. (midnight)


This homework has three parts: two are technical drills and the third part is the creative one. The goal is to make sure that you know how to handle the techical details of developing programs using the Stack class, in the plain or templated version, and then apply it to a simple problem: Matching parentheses. Parts I and II can (and should be) done before the Tuesday class, possibly with some help from the TAs on the technical aspects. For Part III, you should read and understand the problem before Tuesday's class. I will give you extra hints on it on Tuesday, should there be a need.

To avoid conflicts (at least in the usage of the makefile) you must develop each program in a separate directory, and submit them in separate directories.

Part I

Implementation of a Stack abstract data type

Finish the work started as part of Thursday's lab, by implementing the class IntStack and testing it thoroughly using a menu-based test-driver.

Then create two new stack classes, for character and CustRec stacks. Provide a single testdriver for all three of them.

Part II

Templated Stack. Using the templated stack skeleton linked to from Lecture 10, develop a program that fully implements the class and tests it on three types of stacks: integer, character and Customer Record.

Part III

Matching parentheses

Implement a class called Paren (from "parentheses"), which handles correctly parenthesized expressions. Such an expression (a "Paren") is stored as an array of characters, and manipulated via class-specific functions. The constructor initializes an empty Paren expression. The function Input reads in from the user an expression and checks that it contains only the 6 types of characters allowed (open and closed parentheses of three types, (), [] and {}). The function Print prints the expression. The function Match verifies that the expression is correct (all the parentheses match).
To test the class, you will implement a testdriver. Submit all the files (h and cpp), a makefile, a data file and a typescript.
Submit as follows:

For this homework, particular emphasis will be placed on testing, therefore make sure you have tested ALL the functions in your class on significant cases.

Grading guidelines

Ileana Streinu