SlideShare a Scribd company logo
STACK, QUEUE
SANJAY SAHA
STACK: WHAT & WHY
 Collection of elements of same type
 LAST IN FIRST OUT = LIFO
 The last elements that is put in it, is the first one to get out of it!
 Real life examples:
 Plate stack
 Book shelf
 In computer science studies:
 Recursion, function calls
 Infix to prefix, postfix evaluation
 Operating systems
STACK: VISUAL SIMULATION
B
A
D
C
B
A
C
B
A
D
C
B
A
E
D
C
B
A
top
top
top
top
top
A
Input : A, B, C, D, E
popped
STACK: EXAMPLE
 Factorial
 6! = 6 x 5! = 6 x 5 x 4! = … = 6 x 5 x 4 x 3 x 2 x 1
Recursive solution
int fac(int numb){
if(numb<=1)
return 1;
else
return numb*fac(numb-1);
}
fac(1)
fac(2)
fac(3)
fac(4)
fac(5)
fac(6)
2 x 1
3 x 2 x 1
4 x 3 x 2 x 1
5 x 4 x 3 x 2 x 1
6 x 5 x 4 x 3 x 2 x 1
QUEUE: WHAT & WHY
 FIRST IN FIRST OUT = FIFO
 The first elements that is put in it, will be the first one to get served!
 Real life examples:
 Ticket queue
 Restaurant
 In computer science studies:
 Threads
 CPU job scheduling
 Sorting
A
B
A
C
B
A
D
C
B
A
D
C
Brear
front
rear
front
rear
front
rear
front
rear
front
QUEUE: VISUAL SIMULATION
Input : A, B, C, D, E
QUEUE: EXAMPLE
 Circular Queues
 The rear of the queue can be behind the
front
 Effective time utilization
b c d
FrontRear
b c d
FrontRear
e f
e fg
SUMMARY
Stack and queue
Sanjay Saha
University of Dhaka
Thank you!
Ad

Recommended

U3.stack queue
U3.stack queue
Ssankett Negi
 
Data Structures - Lecture 6 [queues]
Data Structures - Lecture 6 [queues]
Muhammad Hammad Waseem
 
My lecture stack_queue_operation
My lecture stack_queue_operation
Senthil Kumar
 
stack & queue
stack & queue
manju rani
 
Stack and queue
Stack and queue
Katang Isip
 
Fallsem2015 16 cp1699-20-jul-2015_rm01_stacks_and_queues
Fallsem2015 16 cp1699-20-jul-2015_rm01_stacks_and_queues
SnehilKeshari
 
Stacks, Queues, Deques
Stacks, Queues, Deques
A-Tech and Software Development
 
Stack and Queue
Stack and Queue
Apurbo Datta
 
03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays
tameemyousaf
 
Stacks and queues
Stacks and queues
Abbott
 
Stack and its operations
Stack and its operations
V.V.Vanniaperumal College for Women
 
Stacks and Queue - Data Structures
Stacks and Queue - Data Structures
Dr. Jasmine Beulah Gnanadurai
 
Stacks and queue
Stacks and queue
Amit Vats
 
Stacks in c++
Stacks in c++
Vineeta Garg
 
Stack queue
Stack queue
Harry Potter
 
Stack and Queue by M.Gomathi Lecturer
Stack and Queue by M.Gomathi Lecturer
gomathi chlm
 
Stack Implementation
Stack Implementation
Zidny Nafan
 
Stacks
Stacks
sardorbek mamazhanov
 
stack presentation
stack presentation
Shivalik college of engineering
 
Stack in Sata Structure
Stack in Sata Structure
Muhazzab Chouhadry
 
Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)
Roman Rodomansky
 
Stacks and queues
Stacks and queues
Trupti Agrawal
 
Queue Data Structure
Queue Data Structure
Lovely Professional University
 
stacks and queues
stacks and queues
DurgaDeviCbit
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked List
PTCL
 
Stack - Data Structure
Stack - Data Structure
Bhavesh Sanghvi
 
Queue data structure
Queue data structure
Mekk Mhmd
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
Stack and Queue......................pptx
Stack and Queue......................pptx
tinotendamcbern91
 

More Related Content

What's hot (19)

03 stacks and_queues_using_arrays
03 stacks and_queues_using_arrays
tameemyousaf
 
Stacks and queues
Stacks and queues
Abbott
 
Stack and its operations
Stack and its operations
V.V.Vanniaperumal College for Women
 
Stacks and Queue - Data Structures
Stacks and Queue - Data Structures
Dr. Jasmine Beulah Gnanadurai
 
Stacks and queue
Stacks and queue
Amit Vats
 
Stacks in c++
Stacks in c++
Vineeta Garg
 
Stack queue
Stack queue
Harry Potter
 
Stack and Queue by M.Gomathi Lecturer
Stack and Queue by M.Gomathi Lecturer
gomathi chlm
 
Stack Implementation
Stack Implementation
Zidny Nafan
 
Stacks
Stacks
sardorbek mamazhanov
 
stack presentation
stack presentation
Shivalik college of engineering
 
Stack in Sata Structure
Stack in Sata Structure
Muhazzab Chouhadry
 
Queue Data Structure (w/ php egs)
Queue Data Structure (w/ php egs)
Roman Rodomansky
 
Stacks and queues
Stacks and queues
Trupti Agrawal
 
Queue Data Structure
Queue Data Structure
Lovely Professional University
 
stacks and queues
stacks and queues
DurgaDeviCbit
 
Queue Implementation Using Array & Linked List
Queue Implementation Using Array & Linked List
PTCL
 
Stack - Data Structure
Stack - Data Structure
Bhavesh Sanghvi
 
Queue data structure
Queue data structure
Mekk Mhmd
 

Similar to Stack and Queue (brief) (20)

Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
Stack and Queue......................pptx
Stack and Queue......................pptx
tinotendamcbern91
 
Stacks and Queues: Essential Data Structures for Efficient Computing with Hiike
Stacks and Queues: Essential Data Structures for Efficient Computing with Hiike
Hiike
 
Stack & Queue
Stack & Queue
Hasan Mahadi Riaz
 
Stacks.pptx in software engineering in simple understanding
Stacks.pptx in software engineering in simple understanding
MohammedAnas871930
 
Module 2 ppt.pptx
Module 2 ppt.pptx
SonaPathak4
 
Stack queue
Stack queue
Majharoddin Kazi
 
STACKS implimentarions AND stack applications .pptx
STACKS implimentarions AND stack applications .pptx
Dr. Amna Mohamed
 
DSA MCA Stack-and-Queue-Data-Structures.pptx
DSA MCA Stack-and-Queue-Data-Structures.pptx
deepuranjankumar08
 
IRJET- Comparison of Stack and Queue Data Structures
IRJET- Comparison of Stack and Queue Data Structures
IRJET Journal
 
Ppt presentation of queues
Ppt presentation of queues
Buxoo Abdullah
 
Difference between stack and queue
Difference between stack and queue
Pulkitmodi1998
 
Data Structures by Maneesh Boddu
Data Structures by Maneesh Boddu
maneesh boddu
 
Understanding the Concepts and Applications of Stack and Queue
Understanding the Concepts and Applications of Stack and Queue
madhuakash830
 
9f556226-babd-4276-b964-371c6a5a77b9.pdf
9f556226-babd-4276-b964-371c6a5a77b9.pdf
kumarharsh2119hk
 
Data Structures - Lecture 2 - Unit 2.pptx
Data Structures - Lecture 2 - Unit 2.pptx
DanielNesaKumarC
 
Introduction to Stack, ▪ Stack ADT, ▪ Implementation of Stack using array, ...
Introduction to Stack, ▪ Stack ADT, ▪ Implementation of Stack using array, ...
Dr. Madhuri Jawale
 
Data structure
Data structure
Rubal Dahat
 
data structure, stack, stack data structure
data structure, stack, stack data structure
pcnmtutorials
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
Stack and Queue......................pptx
Stack and Queue......................pptx
tinotendamcbern91
 
Stacks and Queues: Essential Data Structures for Efficient Computing with Hiike
Stacks and Queues: Essential Data Structures for Efficient Computing with Hiike
Hiike
 
Stacks.pptx in software engineering in simple understanding
Stacks.pptx in software engineering in simple understanding
MohammedAnas871930
 
Module 2 ppt.pptx
Module 2 ppt.pptx
SonaPathak4
 
STACKS implimentarions AND stack applications .pptx
STACKS implimentarions AND stack applications .pptx
Dr. Amna Mohamed
 
DSA MCA Stack-and-Queue-Data-Structures.pptx
DSA MCA Stack-and-Queue-Data-Structures.pptx
deepuranjankumar08
 
IRJET- Comparison of Stack and Queue Data Structures
IRJET- Comparison of Stack and Queue Data Structures
IRJET Journal
 
Ppt presentation of queues
Ppt presentation of queues
Buxoo Abdullah
 
Difference between stack and queue
Difference between stack and queue
Pulkitmodi1998
 
Data Structures by Maneesh Boddu
Data Structures by Maneesh Boddu
maneesh boddu
 
Understanding the Concepts and Applications of Stack and Queue
Understanding the Concepts and Applications of Stack and Queue
madhuakash830
 
9f556226-babd-4276-b964-371c6a5a77b9.pdf
9f556226-babd-4276-b964-371c6a5a77b9.pdf
kumarharsh2119hk
 
Data Structures - Lecture 2 - Unit 2.pptx
Data Structures - Lecture 2 - Unit 2.pptx
DanielNesaKumarC
 
Introduction to Stack, ▪ Stack ADT, ▪ Implementation of Stack using array, ...
Introduction to Stack, ▪ Stack ADT, ▪ Implementation of Stack using array, ...
Dr. Madhuri Jawale
 
data structure, stack, stack data structure
data structure, stack, stack data structure
pcnmtutorials
 
Ad

More from Sanjay Saha (7)

Face Recognition Basic Terminologies
Face Recognition Basic Terminologies
Sanjay Saha
 
Is Face Recognition Safe from Realizable Attacks? - IJCB 2020 - Sanjay Saha, ...
Is Face Recognition Safe from Realizable Attacks? - IJCB 2020 - Sanjay Saha, ...
Sanjay Saha
 
ResNet basics (Deep Residual Network for Image Recognition)
ResNet basics (Deep Residual Network for Image Recognition)
Sanjay Saha
 
Convolutional Deep Belief Nets by Lee. H. 2009
Convolutional Deep Belief Nets by Lee. H. 2009
Sanjay Saha
 
IEEE_802.11e
IEEE_802.11e
Sanjay Saha
 
Image Degradation & Resoration
Image Degradation & Resoration
Sanjay Saha
 
Fault Tree Analysis
Fault Tree Analysis
Sanjay Saha
 
Face Recognition Basic Terminologies
Face Recognition Basic Terminologies
Sanjay Saha
 
Is Face Recognition Safe from Realizable Attacks? - IJCB 2020 - Sanjay Saha, ...
Is Face Recognition Safe from Realizable Attacks? - IJCB 2020 - Sanjay Saha, ...
Sanjay Saha
 
ResNet basics (Deep Residual Network for Image Recognition)
ResNet basics (Deep Residual Network for Image Recognition)
Sanjay Saha
 
Convolutional Deep Belief Nets by Lee. H. 2009
Convolutional Deep Belief Nets by Lee. H. 2009
Sanjay Saha
 
Image Degradation & Resoration
Image Degradation & Resoration
Sanjay Saha
 
Fault Tree Analysis
Fault Tree Analysis
Sanjay Saha
 
Ad

Recently uploaded (20)

Fatality due to Falls at Working at Height
Fatality due to Falls at Working at Height
ssuserb8994f
 
NEW Strengthened Senior High School Gen Math.pptx
NEW Strengthened Senior High School Gen Math.pptx
DaryllWhere
 
Microwatt: Open Tiny Core, Big Possibilities
Microwatt: Open Tiny Core, Big Possibilities
IBM
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Mark Billinghurst
 
Introduction to sensing and Week-1.pptx
Introduction to sensing and Week-1.pptx
KNaveenKumarECE
 
دراسة حاله لقرية تقع في جنوب غرب السودان
دراسة حاله لقرية تقع في جنوب غرب السودان
محمد قصص فتوتة
 
60 Years and Beyond eBook 1234567891.pdf
60 Years and Beyond eBook 1234567891.pdf
waseemalazzeh
 
System design handwritten notes guidance
System design handwritten notes guidance
Shabista Imam
 
special_edition_using_visual_foxpro_6.pdf
special_edition_using_visual_foxpro_6.pdf
Shabista Imam
 
How to Un-Obsolete Your Legacy Keypad Design
How to Un-Obsolete Your Legacy Keypad Design
Epec Engineered Technologies
 
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
Proposal for folders structure division in projects.pdf
Proposal for folders structure division in projects.pdf
Mohamed Ahmed
 
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
resming1
 
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
rr22001247
 
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Shabista Imam
 
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
hosseinihamid192023
 
Modern multi-proposer consensus implementations
Modern multi-proposer consensus implementations
François Garillot
 
20CE404-Soil Mechanics - Slide Share PPT
20CE404-Soil Mechanics - Slide Share PPT
saravananr808639
 
Structural Wonderers_new and ancient.pptx
Structural Wonderers_new and ancient.pptx
nikopapa113
 
Fatality due to Falls at Working at Height
Fatality due to Falls at Working at Height
ssuserb8994f
 
NEW Strengthened Senior High School Gen Math.pptx
NEW Strengthened Senior High School Gen Math.pptx
DaryllWhere
 
Microwatt: Open Tiny Core, Big Possibilities
Microwatt: Open Tiny Core, Big Possibilities
IBM
 
Machine Learning - Classification Algorithms
Machine Learning - Classification Algorithms
resming1
 
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Rapid Prototyping for XR: Lecture 1 Introduction to Prototyping
Mark Billinghurst
 
Introduction to sensing and Week-1.pptx
Introduction to sensing and Week-1.pptx
KNaveenKumarECE
 
دراسة حاله لقرية تقع في جنوب غرب السودان
دراسة حاله لقرية تقع في جنوب غرب السودان
محمد قصص فتوتة
 
60 Years and Beyond eBook 1234567891.pdf
60 Years and Beyond eBook 1234567891.pdf
waseemalazzeh
 
System design handwritten notes guidance
System design handwritten notes guidance
Shabista Imam
 
special_edition_using_visual_foxpro_6.pdf
special_edition_using_visual_foxpro_6.pdf
Shabista Imam
 
Industry 4.o the fourth revolutionWeek-2.pptx
Industry 4.o the fourth revolutionWeek-2.pptx
KNaveenKumarECE
 
Proposal for folders structure division in projects.pdf
Proposal for folders structure division in projects.pdf
Mohamed Ahmed
 
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
resming1
 
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
LECTURE 7 COMPUTATIONS OF LEVELING DATA APRIL 2025.pptx
rr22001247
 
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Shabista Imam
 
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
Call For Papers - 17th International Conference on Wireless & Mobile Networks...
hosseinihamid192023
 
Modern multi-proposer consensus implementations
Modern multi-proposer consensus implementations
François Garillot
 
20CE404-Soil Mechanics - Slide Share PPT
20CE404-Soil Mechanics - Slide Share PPT
saravananr808639
 
Structural Wonderers_new and ancient.pptx
Structural Wonderers_new and ancient.pptx
nikopapa113
 

Stack and Queue (brief)