stack, opeartions on stack, applications of stack

MinaksheePatil 125 views 14 slides Jul 10, 2024
Slide 1
Slide 1 of 14
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14

About This Presentation

stack


Slide Content

STACK

STACK
•Common Example :
•Suppose at your home you have multiple chairs then you put them
together to form a vertical pile. From that vertical pile the chair which is
placed last is always removed first.
Chair which was placed first is removed last. In this way we can see how
stack is related to us.

What is Stack ?
•Stack is used as Linear data structure which can be
accessed from only one end .
•Stack is LIFO Structure [ Last in First Out ]
•Stack is Ordered List of Elements of Same Type.
•Stack is Linear List
•In Stack Operations such as Insertion of an element
is called PUSH and Deletion of an element is called
POP. Both operations permitted at only one end
called Top

Representation of Stack in Memory
Representation of Stack in Memory The stack
•The stack can be implemented into two ways:
◦Using arrays (Static implementation)
◦Using pointer (Dynamic implementation)
implementation)Representation of Stack in
Memory The stack can be implemented into two
ways: ◦Using arrays (Static implementation) ◦
Using pointer (Dynamic implementation)

Visual Representation of Stack :
•View 1 : When Stack is Empty
When Stack is said to empty then it does not contain any element inside it.
Whenever the Stack is Empty the position of topmost element is -1.

•View 2 : When Stack is Not Empty
•Whenever we add very first element then topmost position will be
incremented by 1. After adding First Element top = 0.

•View 3 :
•After Deletion of 1 Element Top Will be Decremented by 1

Operations on Stack
Representation of Stack in Memory The stack
•PUSH:
It adds a new element to the top of the stack.
After every push operation top of stack incremented by
one.
If stack is full no new element can be accommodated,
this condition is called stack overflow or stack is full.

Operations on Stack
Representation of Stack in Memory The stack
•POP:I
It removes the top element from the stack.):
After every pop operation top of stack decremented by
one.
If stack is empty and pop operation performed this will
result into stack underflow condition or stack empty.
he stack

Array Representation of Stack in C
Programming :
•1-D arrayis used to hold the element of the
stack.
•Variable “top” keeps track of “Topmost”
Element in the stack.
•“MAXSIZE” is used as Constant which gives
maximum size of Stack.

PUSH operation on stack

POP operation on stack

APPLICATION OF THE STACK
1.Mathematical Expression Evaluation
2.Expression conversion
a.Infix to Postfix.
b.Infix to Prefix.
c.Postfix to Infix.
d.Prefix to Infix.
3.Parsing
4.Simulation of recursion
5.Function call and recursion
5. Stack frame
6. Reversing a String
Tags