Next: Stack Revisited
Up: Abstract Data Types
Previous: Using CirQ as an
Contents
In this assignment, write a program that implements and tests the stack
ADT. You can borrow some code from the implementation of the circular
queue ADT. To be more specific, first define the type ``StackType'', then
write the following interface subroutines to operate on a stack:
- initializeStack(var s : StackType)
is a procedure to initialize a stack
object so it is empty
- isEmpty(var s : StackType) : boolean
is a function that returns true if and only if
the stack has no elements
- isFull(var s : StackType) : boolean
is a function that returns true if and only if
the stack is full
- push(var s : StackType; v : integer) : boolean
is a function that attempts to put an integer into
a stack, returns true if and only if the operation is successful
- pop(var s : StackType; var v : integer) : boolean
is a function that attempts to remove an integer from
a stack, returns true if and only if the operation is successful
In addition, you also need to write an interactive test program to test
whether the five subroutines are working or not.
Subsections
Next: Stack Revisited
Up: Abstract Data Types
Previous: Using CirQ as an
Contents
Tak Auyeung
2003-12-03