August
1997 QUESTION 4 Total Marks: 20 Marks |
Click here to access other
questions
Click to access |
4. | (a) Define and explain the properties of a stack abstract data-type. In particular, identify any error conditions that may be raised when manipulating a stack. | [3] | |
(b) Define appropriate Pascal type and record definitions for a type called StackType, where | |||
(i) the stack is represented by an array of characters that can only contain a fixed number of characters. | [3] | ||
(ii) the stack of characters can dynamically grow in size. | [3] | ||
(c) List, and give the type definitions, for the basic operations that would form an interface to a stack abstract data type. | [6] | ||
(d) Using the routines you defined as the interface to the stack abstract data type, define a procedure reverse that has the type shown below that takes as its argument a stack of integers, and alter the stack so that the elements that are at the bottom of the stack are moved to the top of the stack, and those at the top move to the bottom. | [5] | ||
Procedure reverse (Var stack: StackType); |