SlideShare a Scribd company logo
1 of 14
Name: Sampad Kar
Student Code: BWU/BTA/22/225
Course Name: Data Structure And
Algorithms
Course Code: BSCM302
Group: D
Session: 2023-24
Understanding
the Stack Data
Structure
Contents
• What is Stack
• Key Operations On a
Stack
• Visualization
• Common Use Cases
• Implementations and
Variations
• Advantages and
Disadvantages
• Examples in
Programming
What is Stack?
Definition:
A stack is a fundamental linear data
structure that follows the Last In, First
Out (LIFO) principle or First In, Last Out
(FILO) Principle.
It means that the last element added to
the stack is the first one to be removed.
Visual Representation:
Imagine a stack of books on a table. We
add books to the top of the stack and
remove them from the same top
position.
Push Operation:
Description: Adds an element to the top
of the stack.
Time Complexity: O(1) - constant time
complexity.
Pop Operation:
Description: Removes the top element
from the stack.
Time Complexity: O(1) - constant time
complexity.
Peek Operation:
Key Operations On a Stack
Display Operation:
Description: Prints or displays the contents
of the stack.
Time Complexity: O(n) - linear time
complexity, where n is the number of
elements in the stack.
IsEmpty Operation:
Checks if the stack is empty.
IsFull Operation:
Checks if the stack is full.
Key Operations On a Stack
Visualization
Implementations and Variations
Array-Based Implementation:
Description: Stacks can be implemented using arrays.
Elements are added or removed from the end of the array,
representing the top of the stack.
Linked List-Based Implementation:
Description: Stacks can also be implemented using linked
lists. Each node in the linked list represents an element in
the stack.
Examples in Programming
Examples in Programming
Examples in Programming
Applications
The following are the applications of stacks
• Evaluating arithmetic expressions
1. Infix To Prefix
2. Infix To Postfix
• Balancing the parenthesis
• Towers of Hanoi
• Function calls
• Tree traversal
Advantages and Disadvantages
Advantages:
• Stacks are simple and intuitive data structures, making them easy to
understand and implement.
• Key operations such as push, pop, and peek have constant time
complexity (O(1)).
Disadvantages:
• Stacks do not support direct access to elements in the middle.
Access is limited to the top element.
• Some stack implementations have fixed-size constraints, limiting the
number of elements that can be stored.
Data Structure - Stacks

More Related Content

Similar to Data Structure - Stacks

Stacks and Queue,Concept of Stack,LIFO,Fifo,
Stacks and Queue,Concept of Stack,LIFO,Fifo,Stacks and Queue,Concept of Stack,LIFO,Fifo,
Stacks and Queue,Concept of Stack,LIFO,Fifo,shaikhdaniyal8603
 
Stacks Data structure.pptx
Stacks Data structure.pptxStacks Data structure.pptx
Stacks Data structure.pptxline24arts
 
Study & Analysis of Complexities of Stack & Queue Operations in Data Structure
Study & Analysis of Complexities of Stack & Queue Operations in Data StructureStudy & Analysis of Complexities of Stack & Queue Operations in Data Structure
Study & Analysis of Complexities of Stack & Queue Operations in Data StructureMeghaj Mallick
 
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4sumitbardhan
 
Stack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTStack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTSoumen Santra
 
Unit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfUnit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfKanchanPatil34
 
Introduction data structure
Introduction data structureIntroduction data structure
Introduction data structureMuhammad Ismail
 
Data Structure
Data Structure Data Structure
Data Structure Ibrahim MH
 
STACKS AND QUEUES.pptx
STACKS AND QUEUES.pptxSTACKS AND QUEUES.pptx
STACKS AND QUEUES.pptxLECO9
 
STACKS AND QUEUES.pptx
STACKS AND QUEUES.pptxSTACKS AND QUEUES.pptx
STACKS AND QUEUES.pptxSKUP1
 

Similar to Data Structure - Stacks (20)

Stack in Sata Structure
Stack in Sata StructureStack in Sata Structure
Stack in Sata Structure
 
Stacks and Queue,Concept of Stack,LIFO,Fifo,
Stacks and Queue,Concept of Stack,LIFO,Fifo,Stacks and Queue,Concept of Stack,LIFO,Fifo,
Stacks and Queue,Concept of Stack,LIFO,Fifo,
 
Stacks Data structure.pptx
Stacks Data structure.pptxStacks Data structure.pptx
Stacks Data structure.pptx
 
Study & Analysis of Complexities of Stack & Queue Operations in Data Structure
Study & Analysis of Complexities of Stack & Queue Operations in Data StructureStudy & Analysis of Complexities of Stack & Queue Operations in Data Structure
Study & Analysis of Complexities of Stack & Queue Operations in Data Structure
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS
 
Data structure.pdf
Data structure.pdfData structure.pdf
Data structure.pdf
 
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
358 33 powerpoint-slides_4-introduction-data-structures_chapter-4
 
Stack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADTStack and its Applications : Data Structures ADT
Stack and its Applications : Data Structures ADT
 
Unit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdfUnit 1_Stack and Queue using Linked Organization.pdf
Unit 1_Stack and Queue using Linked Organization.pdf
 
STACK.pptx
STACK.pptxSTACK.pptx
STACK.pptx
 
Data structures
Data structuresData structures
Data structures
 
Introduction data structure
Introduction data structureIntroduction data structure
Introduction data structure
 
Ds 3
Ds 3Ds 3
Ds 3
 
Stack in C.pptx
Stack in C.pptxStack in C.pptx
Stack in C.pptx
 
5.-Stacks.pptx
5.-Stacks.pptx5.-Stacks.pptx
5.-Stacks.pptx
 
Chapter 6 ds
Chapter 6 dsChapter 6 ds
Chapter 6 ds
 
Week 1 - Data Structures and Algorithms
Week 1 - Data Structures and AlgorithmsWeek 1 - Data Structures and Algorithms
Week 1 - Data Structures and Algorithms
 
Data Structure
Data Structure Data Structure
Data Structure
 
STACKS AND QUEUES.pptx
STACKS AND QUEUES.pptxSTACKS AND QUEUES.pptx
STACKS AND QUEUES.pptx
 
STACKS AND QUEUES.pptx
STACKS AND QUEUES.pptxSTACKS AND QUEUES.pptx
STACKS AND QUEUES.pptx
 

More from Brainware University

More from Brainware University (9)

Python Functions
Python FunctionsPython Functions
Python Functions
 
Basic Logic Gates
Basic Logic GatesBasic Logic Gates
Basic Logic Gates
 
Reduced Instruction Set Computer (RISC)
Reduced Instruction Set Computer (RISC)Reduced Instruction Set Computer (RISC)
Reduced Instruction Set Computer (RISC)
 
Variation Of Parameter (Differential Equations)
Variation Of Parameter (Differential Equations)Variation Of Parameter (Differential Equations)
Variation Of Parameter (Differential Equations)
 
Probability Distribution - Binomial, Exponential and Normal
Probability Distribution - Binomial, Exponential and NormalProbability Distribution - Binomial, Exponential and Normal
Probability Distribution - Binomial, Exponential and Normal
 
Carnot Engine - Thermodynamics
Carnot Engine - ThermodynamicsCarnot Engine - Thermodynamics
Carnot Engine - Thermodynamics
 
Central Tendency - Mean, Median and Mode
Central Tendency - Mean, Median and ModeCentral Tendency - Mean, Median and Mode
Central Tendency - Mean, Median and Mode
 
LAW OF VARIABLE PROPORTIONS
LAW OF VARIABLE PROPORTIONSLAW OF VARIABLE PROPORTIONS
LAW OF VARIABLE PROPORTIONS
 
2D-Arrays
2D-Arrays2D-Arrays
2D-Arrays
 

Recently uploaded

IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Recently uploaded (20)

IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

Data Structure - Stacks

  • 1. Name: Sampad Kar Student Code: BWU/BTA/22/225 Course Name: Data Structure And Algorithms Course Code: BSCM302 Group: D Session: 2023-24
  • 3. Contents • What is Stack • Key Operations On a Stack • Visualization • Common Use Cases • Implementations and Variations • Advantages and Disadvantages • Examples in Programming
  • 4. What is Stack? Definition: A stack is a fundamental linear data structure that follows the Last In, First Out (LIFO) principle or First In, Last Out (FILO) Principle. It means that the last element added to the stack is the first one to be removed. Visual Representation: Imagine a stack of books on a table. We add books to the top of the stack and remove them from the same top position.
  • 5. Push Operation: Description: Adds an element to the top of the stack. Time Complexity: O(1) - constant time complexity. Pop Operation: Description: Removes the top element from the stack. Time Complexity: O(1) - constant time complexity. Peek Operation: Key Operations On a Stack
  • 6. Display Operation: Description: Prints or displays the contents of the stack. Time Complexity: O(n) - linear time complexity, where n is the number of elements in the stack. IsEmpty Operation: Checks if the stack is empty. IsFull Operation: Checks if the stack is full. Key Operations On a Stack
  • 8. Implementations and Variations Array-Based Implementation: Description: Stacks can be implemented using arrays. Elements are added or removed from the end of the array, representing the top of the stack. Linked List-Based Implementation: Description: Stacks can also be implemented using linked lists. Each node in the linked list represents an element in the stack.
  • 12. Applications The following are the applications of stacks • Evaluating arithmetic expressions 1. Infix To Prefix 2. Infix To Postfix • Balancing the parenthesis • Towers of Hanoi • Function calls • Tree traversal
  • 13. Advantages and Disadvantages Advantages: • Stacks are simple and intuitive data structures, making them easy to understand and implement. • Key operations such as push, pop, and peek have constant time complexity (O(1)). Disadvantages: • Stacks do not support direct access to elements in the middle. Access is limited to the top element. • Some stack implementations have fixed-size constraints, limiting the number of elements that can be stored.