SlideShare a Scribd company logo
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

PPT
Stack a Data Structure
PPTX
5.-Stacks.pptx
PPTX
Stack in Data Structoiqowerdjsakdffuh0ownfiuh .pptx
PPTX
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptx
PPTX
Introduction-to-Stack-Instruction.pptxpptppt
PPTX
STACK.pptx
DOCX
Stacks in data structure
PPTX
Stacks in Data Structure
Stack a Data Structure
5.-Stacks.pptx
Stack in Data Structoiqowerdjsakdffuh0ownfiuh .pptx
STACK AND QUEUE CIRCULAR QUEUE PPTS.pptx
Introduction-to-Stack-Instruction.pptxpptppt
STACK.pptx
Stacks in data structure
Stacks in Data Structure

Similar to Data Structure - Stacks (20)

PPTX
STACKS implimentarions AND stack applications .pptx
PPTX
PPTX
Data structure Stack
PPTX
DATA STRUCTURE AND COMPUTER ALGORITHMS LECTURE 2
PPTX
STACK_IN_DATA STRUCTURE AND ALGORITHMS.pptx
PPTX
Stack and Queue
PDF
Stack push pop
PPTX
Data Structure.pptx
PPTX
Data structure
PDF
Chapter 4 stack
PPTX
stack_presentaton_HUSNAIN[2].pojklklklptx
PPT
Lecture 2c stacks
PPTX
The presentation on stack data structure
PPTX
stack.pptx
PPT
Stack data structures with definition and code
PDF
4-Stack --------------------------------in C++.pdf
PDF
The Stack (Data Structccccccccccccccccccc
PPTX
Javascript stack
PPTX
Exploring the Stack Stack Description.pptx
STACKS implimentarions AND stack applications .pptx
Data structure Stack
DATA STRUCTURE AND COMPUTER ALGORITHMS LECTURE 2
STACK_IN_DATA STRUCTURE AND ALGORITHMS.pptx
Stack and Queue
Stack push pop
Data Structure.pptx
Data structure
Chapter 4 stack
stack_presentaton_HUSNAIN[2].pojklklklptx
Lecture 2c stacks
The presentation on stack data structure
stack.pptx
Stack data structures with definition and code
4-Stack --------------------------------in C++.pdf
The Stack (Data Structccccccccccccccccccc
Javascript stack
Exploring the Stack Stack Description.pptx
Ad

More from Sampad Kar (13)

PPTX
Microkernel in Operating System | Operating System
PPTX
Logical Equivalence | Propositional Logic | Discrete Mathematics
PPTX
Turing Machine | Theory Of Computation | Formal Language and Automata Theory
PPTX
Constructor In Java | Object Oriented Programming
PPTX
Python Functions
PPTX
Basic Logic Gates
PPTX
Reduced Instruction Set Computer (RISC)
PPTX
Variation Of Parameter (Differential Equations)
PPTX
Probability Distribution - Binomial, Exponential and Normal
PPTX
Carnot Engine - Thermodynamics
PPTX
Central Tendency - Mean, Median and Mode
PPTX
LAW OF VARIABLE PROPORTIONS
PPTX
2D-Arrays
Microkernel in Operating System | Operating System
Logical Equivalence | Propositional Logic | Discrete Mathematics
Turing Machine | Theory Of Computation | Formal Language and Automata Theory
Constructor In Java | Object Oriented Programming
Python Functions
Basic Logic Gates
Reduced Instruction Set Computer (RISC)
Variation Of Parameter (Differential Equations)
Probability Distribution - Binomial, Exponential and Normal
Carnot Engine - Thermodynamics
Central Tendency - Mean, Median and Mode
LAW OF VARIABLE PROPORTIONS
2D-Arrays
Ad

Recently uploaded (20)

PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
master seminar digital applications in india
PPTX
GDM (1) (1).pptx small presentation for students
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
Lesson notes of climatology university.
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Cell Structure & Organelles in detailed.
PDF
Pre independence Education in Inndia.pdf
human mycosis Human fungal infections are called human mycosis..pptx
master seminar digital applications in india
GDM (1) (1).pptx small presentation for students
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Lesson notes of climatology university.
O7-L3 Supply Chain Operations - ICLT Program
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
STATICS OF THE RIGID BODIES Hibbelers.pdf
Insiders guide to clinical Medicine.pdf
Microbial diseases, their pathogenesis and prophylaxis
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPH.pptx obstetrics and gynecology in nursing
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Supply Chain Operations Speaking Notes -ICLT Program
Abdominal Access Techniques with Prof. Dr. R K Mishra
TR - Agricultural Crops Production NC III.pdf
Basic Mud Logging Guide for educational purpose
Cell Structure & Organelles in detailed.
Pre independence Education in Inndia.pdf

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.