SlideShare a Scribd company logo
DATA STRUCTURE
D AY 3
BY : M O H A M M E D E L S D O D Y
STACK
Stack is a linear data structure which follows a particular order in which the operations
are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out).
Mainly the following three basic operations are performed in the stack:
• Push: Adds an item in the stack. If the stack is full, then it is said to be an Overflow
condition.
• Pop: Removes an item from the stack. The items are popped in the reversed order in
which they are pushed. If the stack is empty, then it is said to be an Underflow
condition.
• Peek or Top: Returns top element of stack.
• isEmpty: Returns true if stack is empty, else false.
STACK
STACK
Time Complexities of operations on stack:
push(), pop(), isEmpty() and peek() all take O(1) time. We do not run any loop in any of
these operations.
APPLICATIONS OF STACK:
• Balancing of symbols.
• Infix to Postfix /Prefix conversion .
• Redo-undo features at many places like editors, photoshop.
• Forward and backward feature in web browsers.
• Used in many algorithms like Tower of Hanoi, tree traversals, stock span
problem, histogram problem.
• Other applications can be Backtracking, Knight tour problem, rat in a maze, N queen
problem and sudoku solver.
• In Graph Algorithms like Topological Sorting and Strongly Connected Components.
IMPLEMENTATION
There are two ways to implement a stack:
• Using array
• Using linked list

More Related Content

PDF
PDF
Algorithm and Data Structure - Queue
PDF
Algorithm and Data Structure - Stack
PPT
Csa stack
PPTX
Stack converted
PPT
Difference between stack and queue
PPT
Algo>Stacks
PPSX
Data Structure (Stack)
Algorithm and Data Structure - Queue
Algorithm and Data Structure - Stack
Csa stack
Stack converted
Difference between stack and queue
Algo>Stacks
Data Structure (Stack)

What's hot (8)

PPTX
Stack and queue
PPTX
Stack Data Structure
PDF
Data structure week y 5
PPTX
Stack & Queue
PPTX
Stack Data structure
PPTX
Bfs and dfs
PPT
Java basics
Stack and queue
Stack Data Structure
Data structure week y 5
Stack & Queue
Stack Data structure
Bfs and dfs
Java basics
Ad

Similar to Data structure day3 (20)

PDF
4-Stack --------------------------------in C++.pdf
PPTX
DSA_Lecture4-Stack.pptx
DOCX
Stacks in data structure
PDF
PPTX
STACK_IN_DATA STRUCTURE AND ALGORITHMS.pptx
PDF
Introduction to Stack.pdf explained stack
PPTX
Stack data structure class 12 cbse 2024.pptx
PPTX
stack_ppt_DSA(sudipta samanta).pptx push,pop,peek operation
PDF
XIICSSTACK_INTRODUCTION cs
PPTX
Stack PPT.pptx
PPTX
Data structure Stack
PDF
The Stack (Data Structccccccccccccccccccc
PPTX
Ds stacks
PPTX
stack.pptx
PDF
Data structure.pdf
PPTX
Introduction to Stack.pptx with stack info
PPTX
Stack in C.pptx
PPT
Stack a Data Structure
PPTX
Stack in Data Structoiqowerdjsakdffuh0ownfiuh .pptx
PPTX
Data Structure - Stacks
4-Stack --------------------------------in C++.pdf
DSA_Lecture4-Stack.pptx
Stacks in data structure
STACK_IN_DATA STRUCTURE AND ALGORITHMS.pptx
Introduction to Stack.pdf explained stack
Stack data structure class 12 cbse 2024.pptx
stack_ppt_DSA(sudipta samanta).pptx push,pop,peek operation
XIICSSTACK_INTRODUCTION cs
Stack PPT.pptx
Data structure Stack
The Stack (Data Structccccccccccccccccccc
Ds stacks
stack.pptx
Data structure.pdf
Introduction to Stack.pptx with stack info
Stack in C.pptx
Stack a Data Structure
Stack in Data Structoiqowerdjsakdffuh0ownfiuh .pptx
Data Structure - Stacks
Ad

More from Mohammed Elsdody (6)

PPTX
Data structure day7
PPTX
Data structure day 6
PPTX
Data structure day5
PPTX
Data structure day4
PPTX
Data structure day1
PPTX
Data structure day 2
Data structure day7
Data structure day 6
Data structure day5
Data structure day4
Data structure day1
Data structure day 2

Recently uploaded (20)

PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Nekopoi APK 2025 free lastest update
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
System and Network Administraation Chapter 3
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
L1 - Introduction to python Backend.pptx
PDF
Digital Strategies for Manufacturing Companies
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Introduction to Artificial Intelligence
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Design an Analysis of Algorithms II-SECS-1021-03
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
How Creative Agencies Leverage Project Management Software.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
Nekopoi APK 2025 free lastest update
Which alternative to Crystal Reports is best for small or large businesses.pdf
PTS Company Brochure 2025 (1).pdf.......
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
CHAPTER 2 - PM Management and IT Context
System and Network Administraation Chapter 3
Navsoft: AI-Powered Business Solutions & Custom Software Development
L1 - Introduction to python Backend.pptx
Digital Strategies for Manufacturing Companies
Softaken Excel to vCard Converter Software.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Introduction to Artificial Intelligence

Data structure day3

  • 1. DATA STRUCTURE D AY 3 BY : M O H A M M E D E L S D O D Y
  • 2. STACK Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). Mainly the following three basic operations are performed in the stack: • Push: Adds an item in the stack. If the stack is full, then it is said to be an Overflow condition. • Pop: Removes an item from the stack. The items are popped in the reversed order in which they are pushed. If the stack is empty, then it is said to be an Underflow condition. • Peek or Top: Returns top element of stack. • isEmpty: Returns true if stack is empty, else false.
  • 4. STACK Time Complexities of operations on stack: push(), pop(), isEmpty() and peek() all take O(1) time. We do not run any loop in any of these operations.
  • 5. APPLICATIONS OF STACK: • Balancing of symbols. • Infix to Postfix /Prefix conversion . • Redo-undo features at many places like editors, photoshop. • Forward and backward feature in web browsers. • Used in many algorithms like Tower of Hanoi, tree traversals, stock span problem, histogram problem. • Other applications can be Backtracking, Knight tour problem, rat in a maze, N queen problem and sudoku solver. • In Graph Algorithms like Topological Sorting and Strongly Connected Components.
  • 6. IMPLEMENTATION There are two ways to implement a stack: • Using array • Using linked list