A stack is either empty, or it consists of two parts:
- a top element
- a stack (the remaining elements)
create_stack
-
- Inputs: none
- Outputs: S (a stack)
- Preconditions: none
- Postconditions: S is defined and empty
destroy_stack
-
- Inputs: S (a stack)
- Outputs: S' (i.e. S changed)
- Preconditions: none
- Postconditions: S' is undefined. All resources (e.g.
memory) allocated to S have been released. No stack
operation can be performed on S'.
is_empty
-
- Inputs: S (a stack)
- Outputs:
is_empty
(boolean)
- Preconditions: none
- Postconditions:
is_empty
is true iff S is
empty.