SlideShare a Scribd company logo
7
Most read
8
Most read
13
Most read
DATA STRUCTURE : ‘STACKS’.
PPO Presentation.
To Understand and apply the knowledge
of the Data Structure ‘Stack’ in the
Application Programs .
Objectives:
 A stack is a linear data structure in which addition or deletion
of element take place at one end only.
 Stack is a special type of data structure where insertion is done
from one end called 'top' of stack and deletion will be done
from the same end. Here, the last element inserted will be on
the top of the stack. Since deletion is done from the same end,
last element inserted is the first element to be deleted.
 So, stack is also called Last In First Out(LIFO)data structure.
Introduction To Stack.
 A stack is an ordered collection of items where
the addition of new items and the removal of
existing items always takes place at the same
end. This end is commonly referred to as the
"TOP". The end opposite the top is known as the
"BASE".
Definition of Stack :
 A stack is a data structure that is used to store
elements but all the elements can be inserted or
deleted from the TOP of the stack.
 The top of the stack is the top most part of the stack,
something like a rectangular box which has only
opening at the top.
Basic Concept of Stack
 The shown figure is a simple
representation of a stack. As we can
notice that the TOP of the stack is the
only means by which we can insert or
delete elements to the stack.
Simple representation of a Stack.
* All the elements in the stack follow the simple rule of Last In First
Out (LIFO). This means that the elements inserted in the last are the
elements to be deleted first.
 1. Max size: This term is used to refer the maximum size of
the stack. This is not a standard term.
 2. Stack empty or underflow : If stack has no elements and
pop operation is performed or an element is deleted from
empty stack then such condition is called as "Underflow".
 3. Overflow or stack full: If stack is full i.e. there is no more
space for new item and push operation is done then such
condition is called as '‘Overflow.''
Terminology:
 createstack( ) :To initializes as an empty stack.
 Insertion / (PUSH) :The process of adding new elements to
the top of stack is called push operation. Pushing of an
element is nothing but adding element to the stack.
 (iii) Deletion / (POP) :The process of deleting an element
from top of a stack is called POP.
Primitive operations on stacks
TOP : A pointer, which keeps track of the top element in the Stack.
If an array of size N is declared to be a stack, then TOP will be -1
when the stack is empty and is N when the stack is full.
isEmpty( ) : This Function is used to check whether a stack is
empty or not. This function returns Boolean value TRUE if stack is
empty .
isFull( ) : This Function is used to check weather a stack becomes
full or not. It returns Boolean TRUE if stack is full else FALSE.
Understanding Push and Pop Operation .
 Infix expressions
 An operator appears between its operands
 Example: a + b
 Prefix expressions
 An operator appears before its operands
 Example: + a b
 Postfix expressions
 An operator appears after its operands
 Example: a b +
Types of Notations:
 To convert a fully parenthesized infix expression to a prefix
form
 Move each operator to the position marked by its corresponding
open parenthesis
 Remove the parentheses
 Example
 Infix expression: ( ( a + b ) * c )
 Prefix expression: * + a b c
Converting an Infix to Prefix Expression.
 To convert a fully parenthesized infix expression to a
postfix form
 Move each operator to the position marked by its
corresponding closing parenthesis
 Remove the parentheses
 Example
 Infix form: ( ( a + b ) * c )
 Postfix form: a b + c *
Converting an Infix to Postfix Expression.
PROGRAMING
Program for static Implementation of Stack using Array.
void push()
{
if(top==MAX)
printf("nn*** STACK OVERFLOW ***nn");
else
{
printf("nn Enter the item to be pushed into the stack:nn");
scanf("%d",&item);
top++;
stack[top]=item;
}
}
void pop()
{
if(top==-1)
printf("nnn*** STACK IS EMPTY !!! ***nn");
else
{
item=stack[top];
top--;
printf("nnn The deleted item from stack is %dnn",item);
}
}
Summary
• A stack is a container of objects that are inserted and removed
according to the Last-In-First-Out (LIFO) principle .
• A stack is a list of elements in which an element may be
inserted or deleted at one end which is known as TOP of the
stack .
• PUSH operation adds an item to the top of the stack while
POP removes the item from the top .
• The process of writing the operators of an expression either
before their operands or after them is called Polish notation .
Thank you !!!

More Related Content

PPTX
Searching and sorting
PPTX
Stack - Data Structure
PPSX
PPTX
Stack_Data_Structure.pptx
PDF
Applications of stack
PPT
Breadth first search
PPTX
Doubly linked list (animated)
PPT
Searching and sorting
Stack - Data Structure
Stack_Data_Structure.pptx
Applications of stack
Breadth first search
Doubly linked list (animated)

What's hot (20)

PPTX
Introduction to stack
PPT
Queue Data Structure
PPTX
PPTX
Stack using Array
PPTX
Trees in data structures
PPSX
Stacks Implementation and Examples
PPT
Doubly linked list
PPTX
Data structure by Digvijay
PPTX
sorting and its types
PPT
Stack & queue
PPTX
Data structure and its types
PPTX
Stack and Queue by M.Gomathi Lecturer
PPTX
Binary Tree in Data Structure
PDF
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
PPTX
Linked List
PPTX
Linked list
PPTX
Stack & Queue using Linked List in Data Structure
PPT
Stack a Data Structure
PPT
Introduction to stack
Queue Data Structure
Stack using Array
Trees in data structures
Stacks Implementation and Examples
Doubly linked list
Data structure by Digvijay
sorting and its types
Stack & queue
Data structure and its types
Stack and Queue by M.Gomathi Lecturer
Binary Tree in Data Structure
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
Linked List
Linked list
Stack & Queue using Linked List in Data Structure
Stack a Data Structure
Ad

Viewers also liked (20)

PPSX
Data Structure (Stack)
PPTX
Stack Data structure
PPT
Stack Data Structure & It's Application
PPT
Stack Data Structure V1.0
PPTX
Stack Data Structre Introduction and source code
PPT
PPT
data structure, stack, stack data structure
PPT
03 stacks and_queues_using_arrays
PPT
Application of Stacks
PPTX
Stack data structure
PPTX
STACKS IN DATASTRUCTURE
PDF
Algoritma dan Pemrograman C++ (Percabangan)
PPTX
Array menu
PDF
stack
PPT
Presentation about arrays
PPTX
Data Structures - Lecture 5 [Stack]
PPT
Arrays
PPT
2 arrays
DOCX
Act 8. tallerpractico10 ilia-cabarcas
Data Structure (Stack)
Stack Data structure
Stack Data Structure & It's Application
Stack Data Structure V1.0
Stack Data Structre Introduction and source code
data structure, stack, stack data structure
03 stacks and_queues_using_arrays
Application of Stacks
Stack data structure
STACKS IN DATASTRUCTURE
Algoritma dan Pemrograman C++ (Percabangan)
Array menu
stack
Presentation about arrays
Data Structures - Lecture 5 [Stack]
Arrays
2 arrays
Act 8. tallerpractico10 ilia-cabarcas
Ad

Similar to Data structure Stack (20)

PPTX
Stacks in c++
PPT
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
PPT
stack is an ordered list in which insertion and deletion are done at one end,...
PPT
Linear Datsructure_stacks_Data Structure_PPT.ppt
PPT
stack data structure and its applications , advantages, disadvantages etc
PPT
stack data structure , applications, advantages
PPTX
Data Structures Stack and Queue Data Structures
PPTX
Stack data structure
PPTX
Stacks Data structure.pptx
PPT
Stack data structures with definition and code
PPTX
Stack and its operations, Queue and its operations
PPTX
Abscddnddmdkwkkstack implementation.pptx
DOCX
Stacks in data structure
PPTX
Unit 3 stack
PPTX
Stacks and queues using aaray line .pptx
PDF
STACK ( LIFO STRUCTURE) - Data Structure
PPTX
Introduction to information about Data Structure.pptx
PPTX
DATA STRUCTURE - STACK
PPT
Lect 15-16 Zaheer Abbas
PDF
Stacks in c++
Stack ppt file of Stack DSA For lab in the lab of DSA lecture and Lab.ppt
stack is an ordered list in which insertion and deletion are done at one end,...
Linear Datsructure_stacks_Data Structure_PPT.ppt
stack data structure and its applications , advantages, disadvantages etc
stack data structure , applications, advantages
Data Structures Stack and Queue Data Structures
Stack data structure
Stacks Data structure.pptx
Stack data structures with definition and code
Stack and its operations, Queue and its operations
Abscddnddmdkwkkstack implementation.pptx
Stacks in data structure
Unit 3 stack
Stacks and queues using aaray line .pptx
STACK ( LIFO STRUCTURE) - Data Structure
Introduction to information about Data Structure.pptx
DATA STRUCTURE - STACK
Lect 15-16 Zaheer Abbas

Recently uploaded (20)

PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Welding lecture in detail for understanding
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
composite construction of structures.pdf
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PDF
PPT on Performance Review to get promotions
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Construction Project Organization Group 2.pptx
PPTX
Sustainable Sites - Green Building Construction
PDF
Digital Logic Computer Design lecture notes
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
bas. eng. economics group 4 presentation 1.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
Welding lecture in detail for understanding
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
CH1 Production IntroductoryConcepts.pptx
Foundation to blockchain - A guide to Blockchain Tech
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
composite construction of structures.pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPT on Performance Review to get promotions
CYBER-CRIMES AND SECURITY A guide to understanding
UNIT 4 Total Quality Management .pptx
Construction Project Organization Group 2.pptx
Sustainable Sites - Green Building Construction
Digital Logic Computer Design lecture notes

Data structure Stack

  • 1. DATA STRUCTURE : ‘STACKS’. PPO Presentation.
  • 2. To Understand and apply the knowledge of the Data Structure ‘Stack’ in the Application Programs . Objectives:
  • 3.  A stack is a linear data structure in which addition or deletion of element take place at one end only.  Stack is a special type of data structure where insertion is done from one end called 'top' of stack and deletion will be done from the same end. Here, the last element inserted will be on the top of the stack. Since deletion is done from the same end, last element inserted is the first element to be deleted.  So, stack is also called Last In First Out(LIFO)data structure. Introduction To Stack.
  • 4.  A stack is an ordered collection of items where the addition of new items and the removal of existing items always takes place at the same end. This end is commonly referred to as the "TOP". The end opposite the top is known as the "BASE". Definition of Stack :
  • 5.  A stack is a data structure that is used to store elements but all the elements can be inserted or deleted from the TOP of the stack.  The top of the stack is the top most part of the stack, something like a rectangular box which has only opening at the top. Basic Concept of Stack
  • 6.  The shown figure is a simple representation of a stack. As we can notice that the TOP of the stack is the only means by which we can insert or delete elements to the stack. Simple representation of a Stack. * All the elements in the stack follow the simple rule of Last In First Out (LIFO). This means that the elements inserted in the last are the elements to be deleted first.
  • 7.  1. Max size: This term is used to refer the maximum size of the stack. This is not a standard term.  2. Stack empty or underflow : If stack has no elements and pop operation is performed or an element is deleted from empty stack then such condition is called as "Underflow".  3. Overflow or stack full: If stack is full i.e. there is no more space for new item and push operation is done then such condition is called as '‘Overflow.'' Terminology:
  • 8.  createstack( ) :To initializes as an empty stack.  Insertion / (PUSH) :The process of adding new elements to the top of stack is called push operation. Pushing of an element is nothing but adding element to the stack.  (iii) Deletion / (POP) :The process of deleting an element from top of a stack is called POP. Primitive operations on stacks
  • 9. TOP : A pointer, which keeps track of the top element in the Stack. If an array of size N is declared to be a stack, then TOP will be -1 when the stack is empty and is N when the stack is full. isEmpty( ) : This Function is used to check whether a stack is empty or not. This function returns Boolean value TRUE if stack is empty . isFull( ) : This Function is used to check weather a stack becomes full or not. It returns Boolean TRUE if stack is full else FALSE.
  • 10. Understanding Push and Pop Operation .
  • 11.  Infix expressions  An operator appears between its operands  Example: a + b  Prefix expressions  An operator appears before its operands  Example: + a b  Postfix expressions  An operator appears after its operands  Example: a b + Types of Notations:
  • 12.  To convert a fully parenthesized infix expression to a prefix form  Move each operator to the position marked by its corresponding open parenthesis  Remove the parentheses  Example  Infix expression: ( ( a + b ) * c )  Prefix expression: * + a b c Converting an Infix to Prefix Expression.
  • 13.  To convert a fully parenthesized infix expression to a postfix form  Move each operator to the position marked by its corresponding closing parenthesis  Remove the parentheses  Example  Infix form: ( ( a + b ) * c )  Postfix form: a b + c * Converting an Infix to Postfix Expression.
  • 15. Program for static Implementation of Stack using Array. void push() { if(top==MAX) printf("nn*** STACK OVERFLOW ***nn"); else { printf("nn Enter the item to be pushed into the stack:nn"); scanf("%d",&item); top++; stack[top]=item; } }
  • 16. void pop() { if(top==-1) printf("nnn*** STACK IS EMPTY !!! ***nn"); else { item=stack[top]; top--; printf("nnn The deleted item from stack is %dnn",item); } }
  • 17. Summary • A stack is a container of objects that are inserted and removed according to the Last-In-First-Out (LIFO) principle . • A stack is a list of elements in which an element may be inserted or deleted at one end which is known as TOP of the stack . • PUSH operation adds an item to the top of the stack while POP removes the item from the top . • The process of writing the operators of an expression either before their operands or after them is called Polish notation .