SlideShare a Scribd company logo
Stack Operation
ANUJ RANA
BCA
Insertion in Stack
 When an object is added to a stack, it is placed on the top of all previously
entered items.
 When an item is removed, it can either be removed from the top.
 LIFO (Last in First Out ) method is used in stack operation.
What is Stack?
 Stack is data structure used to store a collection of objects.
 Individual items can be added and stored in a stack using a push operation.
 Objects can be retrieved using a pop operation, which removes an item from the
stack.
How?
Top
Bottom
Push
Pop
Static Memory allocation
2040
2050
2046
2048
2042
2052
Int stack[6]
0
1
2
3
4
5
-1
Stack Operation
 Top: Open end of the stack is called Top, From this end item can be inserted.
 Push: To insert an item from Top of stack is called push operation. The push
operation change the position of Top in stack.
 POP: To put-off, get or remove some item from top of the stack is the pop
operation, We can POP only from top of the stack.
 IsEmpty: Stack considered empty when there is no item on Top. IsEmpty operation
return true when no item in stack else false
 IsFull: Stack considered full if no other element can be inserted on top of the
stack. This condition normally occur when stack implement ed through array.
Stack example
Empty
Stack 5 5 5
7
8
7
7
5 5
6
5
Push 5 Push 7 Push 8
Pop 8 Pop 7 Push 6 Pop 6
Pop 5
Empty
Stack
Implementation of Stack using Array.

More Related Content

What's hot

Stacks overview with its applications
Stacks overview with its applicationsStacks overview with its applications
Stacks overview with its applications
Saqib Saeed
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
vaibhav2910
 
data structure, stack, stack data structure
data structure, stack, stack data structuredata structure, stack, stack data structure
data structure, stack, stack data structure
pcnmtutorials
 

What's hot (18)

Stack push pop
Stack push popStack push pop
Stack push pop
 
Stack a Data Structure
Stack a Data StructureStack a Data Structure
Stack a Data Structure
 
Stacks in Data Structure
Stacks in Data StructureStacks in Data Structure
Stacks in Data Structure
 
Data Structure (Stack)
Data Structure (Stack)Data Structure (Stack)
Data Structure (Stack)
 
Project of data structure
Project of data structureProject of data structure
Project of data structure
 
Stacks overview with its applications
Stacks overview with its applicationsStacks overview with its applications
Stacks overview with its applications
 
Introduction to stack
Introduction to stackIntroduction to stack
Introduction to stack
 
Stacks
StacksStacks
Stacks
 
data structure, stack, stack data structure
data structure, stack, stack data structuredata structure, stack, stack data structure
data structure, stack, stack data structure
 
stack and queue array implementation in java.
stack and queue array implementation in java.stack and queue array implementation in java.
stack and queue array implementation in java.
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTURE
 
Queue Data Structure
Queue Data StructureQueue Data Structure
Queue Data Structure
 
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data Structure
 
Unit I-Data structures stack & Queue
Unit I-Data structures stack & QueueUnit I-Data structures stack & Queue
Unit I-Data structures stack & Queue
 
Algorithm and Data Structure - Stack
Algorithm and Data Structure - StackAlgorithm and Data Structure - Stack
Algorithm and Data Structure - Stack
 
Algorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAlgorithm and Data Structure - Queue
Algorithm and Data Structure - Queue
 
Stack project
Stack projectStack project
Stack project
 
Stack
StackStack
Stack
 

Similar to Stack operation

Similar to Stack operation (20)

Stack PPT.pptx
Stack PPT.pptxStack PPT.pptx
Stack PPT.pptx
 
Operation on stack
Operation on stackOperation on stack
Operation on stack
 
Stack
StackStack
Stack
 
Stack
StackStack
Stack
 
Difference between stack and queue
Difference between stack and queueDifference between stack and queue
Difference between stack and queue
 
Stack in Data Structure
Stack in Data StructureStack in Data Structure
Stack in Data Structure
 
Why does the stack use a FILO (first in last out) schemeSolutio.pdf
Why does the stack use a FILO (first in last out) schemeSolutio.pdfWhy does the stack use a FILO (first in last out) schemeSolutio.pdf
Why does the stack use a FILO (first in last out) schemeSolutio.pdf
 
Chapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdfChapter 5 Stack and Queue.pdf
Chapter 5 Stack and Queue.pdf
 
Data structure.pdf
Data structure.pdfData structure.pdf
Data structure.pdf
 
Data structure Stack
Data structure StackData structure Stack
Data structure Stack
 
Chapter 5-stack.pptx
Chapter 5-stack.pptxChapter 5-stack.pptx
Chapter 5-stack.pptx
 
STACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data StructureSTACK ( LIFO STRUCTURE) - Data Structure
STACK ( LIFO STRUCTURE) - Data Structure
 
Lecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptxLecture#5 - Stack ADT.pptx
Lecture#5 - Stack ADT.pptx
 
In C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docxIn C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docx
 
Module 2 ppt.pptx
Module 2 ppt.pptxModule 2 ppt.pptx
Module 2 ppt.pptx
 
Ds stacks
Ds stacksDs stacks
Ds stacks
 
VCE Unit 03vv.pptx
VCE Unit 03vv.pptxVCE Unit 03vv.pptx
VCE Unit 03vv.pptx
 
Stack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparationStack and Queue.pptx university exam preparation
Stack and Queue.pptx university exam preparation
 
Stacks Data structure.pptx
Stacks Data structure.pptxStacks Data structure.pptx
Stacks Data structure.pptx
 
stack coding.pptx
stack coding.pptxstack coding.pptx
stack coding.pptx
 

Recently uploaded

Investigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_CrimesInvestigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_Crimes
StarCompliance.io
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
ewymefz
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
ewymefz
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Domenico Conte
 
Computer Presentation.pptx ecommerce advantage s
Computer Presentation.pptx ecommerce advantage sComputer Presentation.pptx ecommerce advantage s
Computer Presentation.pptx ecommerce advantage s
MAQIB18
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
nscud
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
Opendatabay
 

Recently uploaded (20)

Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationPredicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
 
Investigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_CrimesInvestigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_Crimes
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
 
Using PDB Relocation to Move a Single PDB to Another Existing CDB
Using PDB Relocation to Move a Single PDB to Another Existing CDBUsing PDB Relocation to Move a Single PDB to Another Existing CDB
Using PDB Relocation to Move a Single PDB to Another Existing CDB
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
 
Uber Ride Supply Demand Gap Analysis Report
Uber Ride Supply Demand Gap Analysis ReportUber Ride Supply Demand Gap Analysis Report
Uber Ride Supply Demand Gap Analysis Report
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
 
Computer Presentation.pptx ecommerce advantage s
Computer Presentation.pptx ecommerce advantage sComputer Presentation.pptx ecommerce advantage s
Computer Presentation.pptx ecommerce advantage s
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
一比一原版(CBU毕业证)不列颠海角大学毕业证成绩单
 
Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPsWebinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
 
How can I successfully sell my pi coins in Philippines?
How can I successfully sell my pi coins in Philippines?How can I successfully sell my pi coins in Philippines?
How can I successfully sell my pi coins in Philippines?
 

Stack operation

  • 2. Insertion in Stack  When an object is added to a stack, it is placed on the top of all previously entered items.  When an item is removed, it can either be removed from the top.  LIFO (Last in First Out ) method is used in stack operation.
  • 3. What is Stack?  Stack is data structure used to store a collection of objects.  Individual items can be added and stored in a stack using a push operation.  Objects can be retrieved using a pop operation, which removes an item from the stack.
  • 6. Stack Operation  Top: Open end of the stack is called Top, From this end item can be inserted.  Push: To insert an item from Top of stack is called push operation. The push operation change the position of Top in stack.  POP: To put-off, get or remove some item from top of the stack is the pop operation, We can POP only from top of the stack.  IsEmpty: Stack considered empty when there is no item on Top. IsEmpty operation return true when no item in stack else false  IsFull: Stack considered full if no other element can be inserted on top of the stack. This condition normally occur when stack implement ed through array.
  • 7. Stack example Empty Stack 5 5 5 7 8 7 7 5 5 6 5 Push 5 Push 7 Push 8 Pop 8 Pop 7 Push 6 Pop 6 Pop 5 Empty Stack
  • 8. Implementation of Stack using Array.