Stack is a linear data structure
In case of array , insertion and deletion take place
at any position
Stack is an ordered collection of homogenous data
elements where the insertion and deletion
operation takes place at one end only
It is a Last in First Out (LIFO) memory
CS KTU Lectures
, OPERATIONS ON STACK
PUSH- Insert an element into the stack
POP- Delete an element from the stack
STATUS- To Know the present state of stack
DISPLAY – To display the elements of the stack
Some Terminologies
TOP- Position of the stack where PUSH and POP
operations are performed
ITEM – An element in a stack
SIZE – Maximum number of elements that a
stack can accommodate
CS KTU Lectures
, STACK
POP
PUSH
ITEM 8 TOP
ITEM 7
ITEM 6
ITEM 5
ITEM 4
ITEM 3
ITEM 2
ITEM 1
CS KTU Lectures
, STACK
Real time examples:
Trains in a railway yard
Shipment of cargo
Applications of Stack:
Evaluation of Arithmetic Expressions
Implementation of Recursion
CS KTU Lectures