Data Structure
Data Structure
CA 1 Examination
Definition of stack
Working principle
Operations
(Push,Pop,Peek,Disply)
Application
What is
stack ?
Stacks are linear data structures that follows a
particular method called LIFO. A Stack can be
a fixed specific size, or it can be dynamic, i.e.,
the Stack size can be changed dynamically
Implementatio
n of Stack :
In terms of implementation, stacks
are typically implemented using
an array or linked list. The two
main operations of a stack are
push and pop.
WORKING PRINCIPLE
It works on the principle of LIFO
(Last In First Out) or FILO (First In
Last Out)
Step 1 : Start
3
2 2
Step 2 : If TOP = 1
1 1
Print “Underflow”
Go to Step 5
Step 3 : Return
Stack[TOP]
Step 4 : End .
PEEK OPERATION
ALGORITH
M
Step 1 : Start . 4
3
2
Step 2 : If (top == -1) ,
1
then the stack is empty,
print “The Stack is The Stack is The Stack is
Full Empty
Empty”.