Professional Documents
Culture Documents
Stacks
Stacks
A STACK is a linear structure in which items may be added or removed only at one end
A STACK is a list of elements in which an element may be inserted or deleted only at one end , called the
top
of the stack
TERMINOLOGY
EMPTY
FULL
PUSH(STACK,TOP,MAXSTK,ITEM) If TOP=MAXSTK then Print OVERFLOW and return Set TOP=TOP+1 Set STACK[TOP]=ITEM RETURN
POP(STACK,TOP,ITEM) If TOP =0 then Print UNDERFLOW and RETURN Set ITEM=STACK[TOP] Set TOP=TOP-1 Return