Operations on a stack
• initialize(stack)--- clear the stack
• empty(stack)--- check to see if the
stack is empty
• full(stack)--- check to see if the
stack is full
• push(el,stack)--- put the element
elon the top of the stack
• pop(stack)--- take the topmost
element from the stack
• How to implement a stack?
stack implementation using structure
• Implementation (c): stack is declared as a
structurewith two fields: one for storage,
one for keeping track of the topmost
position
#define Max 50
typedef int Eltype;
typedef struct StackRec {
Eltype storage[Max];
int top;
};
typedef struct StackRec StackType;