SlideShare a Scribd company logo
5
Most read
6
Most read
7
Most read
Stack operation algorithms
with example
KIKANI NAMAN BHARATBHAI
20SS02IT027
DATA STRUCTURES
What is Stack?
• A stack is called a last-in-first-out (LIFO) collection. This
means that the last thing we added (pushed) is the first thing
that gets pulled (popped) off.
• A stack is a sequence of items that are accessible at only one
end of the sequence.
Operations that can be performed on STACK:
 PUSH.
 POP.
Procedure/Methodology
PUSH : It is used to insert items into the stack.
POP: It is used to delete items from stack.
TOP: It represents the current location of data in stack.
ALGORITHM OF INSERTION IN STACK: (PUSH)
1. Insertion(a,top,item,max)
2. If top=max then
3. print ‘STACK OVERFLOW’
4. exit else
5. top=top+1 end if
6. a[top]=item
7. Exit
ALGORITHM OF DELETION IN STACK: (POP)
1. Deletion(a,top,item)
2. If top=0 then
3. print ‘STACK UNDERFLOW’
4. exit else
5. item=a[top] end if
6. top=top-1
7. Exit
ALGORITHM OF DISPLAY IN STACK:
• 1. Display(top,i,a[i]) 2.If top=0 then
• 2. Print ‘STACK EMPTY’
• Exit Else
• 3. For i=top to 0
• Print a[i] End for
• 4. exit
Conversion of INFIX to POSTFIX conversion:
• Example: 2+(4-1)*3 step1
• 2+41-*3 step2
• 2+41-3* step3
• 241-3*+ step4
Example:
THANK YOU

More Related Content

PPTX
PPTX
Stacks IN DATA STRUCTURES
PPTX
B and B+ tree
PDF
PDF
Applications of stack
PPT
Heap tree
PPT
Data Structures- Part5 recursion
PPTX
STACKS IN DATASTRUCTURE
Stacks IN DATA STRUCTURES
B and B+ tree
Applications of stack
Heap tree
Data Structures- Part5 recursion
STACKS IN DATASTRUCTURE

What's hot (20)

PPTX
Polish Notation In Data Structure
PPTX
Polymorphism In c++
PPTX
Conversion of Infix to Prefix and Postfix with Stack
PPTX
Doubly Linked List
PPTX
Data Structures - Lecture 7 [Linked List]
PPT
One Dimensional Array
PPT
Stacks
PPTX
Top down parsing
PPTX
Method overloading
PPT
Data structures using c
PPT
Linked list
PPT
PPT
Thread model in java
PPSX
Data Structure (Tree)
PPTX
heap Sort Algorithm
PPT
PPT
Abstract data types
PDF
Python list
PPTX
Type casting in c programming
PPTX
Inheritance in java
Polish Notation In Data Structure
Polymorphism In c++
Conversion of Infix to Prefix and Postfix with Stack
Doubly Linked List
Data Structures - Lecture 7 [Linked List]
One Dimensional Array
Stacks
Top down parsing
Method overloading
Data structures using c
Linked list
Thread model in java
Data Structure (Tree)
heap Sort Algorithm
Abstract data types
Python list
Type casting in c programming
Inheritance in java
Ad

Similar to Stack operation algorithms with example (20)

PPTX
Ds stacks
PPTX
Stack PPT.pptx
PPT
Lect 15-16 Zaheer Abbas
PPTX
Stack and Queue.pptx university exam preparation
PDF
04 stacks
PDF
STACK ( LIFO STRUCTURE) - Data Structure
PDF
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
PDF
Chapter 5 Stack and Queue.pdf
PPTX
Data structure by Digvijay
PPT
Stack data structures with definition and code
PPTX
STACK_IN_DATA STRUCTURE AND ALGORITHMS.pptx
PPTX
6 - STACKS in Data Structure and Algorithm.pptx
PPTX
Stacks Data structure.pptx
DOCX
Stack - Operations and Applications
PPTX
Stack data structure
PPTX
Stack.pptx
PPTX
Project of data structure
PPTX
PDF
Stack concepts by Divya
DOCX
In C++ a function used to put data into a stack is typically called a.docx
Ds stacks
Stack PPT.pptx
Lect 15-16 Zaheer Abbas
Stack and Queue.pptx university exam preparation
04 stacks
STACK ( LIFO STRUCTURE) - Data Structure
What is Stack, Its Operations, Queue, Circular Queue, Priority Queue
Chapter 5 Stack and Queue.pdf
Data structure by Digvijay
Stack data structures with definition and code
STACK_IN_DATA STRUCTURE AND ALGORITHMS.pptx
6 - STACKS in Data Structure and Algorithm.pptx
Stacks Data structure.pptx
Stack - Operations and Applications
Stack data structure
Stack.pptx
Project of data structure
Stack concepts by Divya
In C++ a function used to put data into a stack is typically called a.docx
Ad

Recently uploaded (20)

PDF
Classroom Observation Tools for Teachers
PDF
Basic Mud Logging Guide for educational purpose
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Pre independence Education in Inndia.pdf
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
Cell Structure & Organelles in detailed.
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
01-Introduction-to-Information-Management.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Business Ethics Teaching Materials for college
PPTX
Institutional Correction lecture only . . .
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
master seminar digital applications in india
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PDF
Insiders guide to clinical Medicine.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
Classroom Observation Tools for Teachers
Basic Mud Logging Guide for educational purpose
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Pre independence Education in Inndia.pdf
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
Cell Structure & Organelles in detailed.
Final Presentation General Medicine 03-08-2024.pptx
01-Introduction-to-Information-Management.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Business Ethics Teaching Materials for college
Institutional Correction lecture only . . .
Renaissance Architecture: A Journey from Faith to Humanism
VCE English Exam - Section C Student Revision Booklet
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
master seminar digital applications in india
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Insiders guide to clinical Medicine.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025

Stack operation algorithms with example

  • 1. Stack operation algorithms with example KIKANI NAMAN BHARATBHAI 20SS02IT027 DATA STRUCTURES
  • 2. What is Stack? • A stack is called a last-in-first-out (LIFO) collection. This means that the last thing we added (pushed) is the first thing that gets pulled (popped) off. • A stack is a sequence of items that are accessible at only one end of the sequence.
  • 3. Operations that can be performed on STACK:  PUSH.  POP.
  • 4. Procedure/Methodology PUSH : It is used to insert items into the stack. POP: It is used to delete items from stack. TOP: It represents the current location of data in stack.
  • 5. ALGORITHM OF INSERTION IN STACK: (PUSH) 1. Insertion(a,top,item,max) 2. If top=max then 3. print ‘STACK OVERFLOW’ 4. exit else 5. top=top+1 end if 6. a[top]=item 7. Exit
  • 6. ALGORITHM OF DELETION IN STACK: (POP) 1. Deletion(a,top,item) 2. If top=0 then 3. print ‘STACK UNDERFLOW’ 4. exit else 5. item=a[top] end if 6. top=top-1 7. Exit
  • 7. ALGORITHM OF DISPLAY IN STACK: • 1. Display(top,i,a[i]) 2.If top=0 then • 2. Print ‘STACK EMPTY’ • Exit Else • 3. For i=top to 0 • Print a[i] End for • 4. exit
  • 8. Conversion of INFIX to POSTFIX conversion: • Example: 2+(4-1)*3 step1 • 2+41-*3 step2 • 2+41-3* step3 • 241-3*+ step4

Editor's Notes