SlideShare a Scribd company logo
1 of 11
QUEUES
A U T H O R : T U S I F U E D I S O N
DEFINITION
• Queue is a linear data structure where elements are ordered
in special fashion.
i.e. FIFO(First IN First Out). Which means element inserted first
to the queue will be removed first from the queue.
In other words: queue is a list or collection with the restriction
or constraints that insertion can be performed at one end (rear
or tail) and deletion can be performed at other end(front or
head)
Author:Tusifu Edison
ROLE OF THE QUEUES
Queue is most often used in a scenario where there is a
shared resource that’s supposed to serve some request but
the resource can handle only one request at a time.
A machine has a processor to process different
programs(or to execute all instructions), and it has the
ability to process one program at a time, so the processes
are put in the queue.
For the front process to be terminated
Author:Tusifu Edison
IMPLEMENTING QUEUES WITH LINKED
LIST VS ARRAY
Main disadvantages of implementing queues with arrays
And linked list is the solution
• By using array list you may store large memory which you will
not use,
• The array may get filled when you have other elements you
want to insert
That will cause to stop the insertion or create another big array
and copy the first array
And add the elements which you wantAuthor:Tusifu Edison
OPERATIONS AVAILABLE WITH QUEUE
• EnQueue(x) or push (x):insertion of element at the the rear or
the tail of the queue.
• Dequeue() or pop():deletion the element from the front or
head of the queue.
• Front() or peek():to look the element at the front
• Is empty():check if the queue is empty or not
Example:
NB: all of this operations has the constant time or O(1)
Author:Tusifu Edison
ENQUEUE
Author:Tusifu Edison
DEQUEUE EXPLANATION
Author:Tusifu Edison
ENQUEUE IMPLEMENTATION USING
LINKED LIST (STRUCT+MAIN)
Author:Tusifu Edison
ENQUEUE AN ELEMENT IN THE QUEUE
USING THE LINKED LIST
Author:Tusifu Edison
DEQUEUE AN ELEMENT FROM THE
QUEUE USING THE LINKED LIST
Author:Tusifu Edison
THE END

More Related Content

What's hot

Python advanced 3.the python std lib by example – algorithm
Python advanced 3.the python std lib by example – algorithmPython advanced 3.the python std lib by example – algorithm
Python advanced 3.the python std lib by example – algorithm
John(Qiang) Zhang
 
Numpy and scipy
Numpy and scipyNumpy and scipy
Numpy and scipy
tarun_483
 

What's hot (20)

basics of queues
basics of queuesbasics of queues
basics of queues
 
Data Structures 2
Data Structures 2Data Structures 2
Data Structures 2
 
Queues-and-CQueue-Implementation
Queues-and-CQueue-ImplementationQueues-and-CQueue-Implementation
Queues-and-CQueue-Implementation
 
Stack Data structure
Stack Data structureStack Data structure
Stack Data structure
 
Data Structure And Queue
Data Structure And Queue Data Structure And Queue
Data Structure And Queue
 
DATA STRUCTURE IN C LANGUAGE
DATA STRUCTURE IN C LANGUAGEDATA STRUCTURE IN C LANGUAGE
DATA STRUCTURE IN C LANGUAGE
 
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data Structure
 
Queue
QueueQueue
Queue
 
Stack & Queue
Stack & QueueStack & Queue
Stack & Queue
 
Stacks
StacksStacks
Stacks
 
Algorithm and Data Structure - Queue
Algorithm and Data Structure - QueueAlgorithm and Data Structure - Queue
Algorithm and Data Structure - Queue
 
Algorithm and Data Structure - Stack
Algorithm and Data Structure - StackAlgorithm and Data Structure - Stack
Algorithm and Data Structure - Stack
 
Data strucer
Data strucerData strucer
Data strucer
 
Implementation of queue using singly and doubly linked list.
Implementation of queue using singly and doubly linked list.Implementation of queue using singly and doubly linked list.
Implementation of queue using singly and doubly linked list.
 
MySQL Performance Optimization #NEOJUG12
MySQL Performance Optimization #NEOJUG12MySQL Performance Optimization #NEOJUG12
MySQL Performance Optimization #NEOJUG12
 
Kaggle tokyo 2018
Kaggle tokyo 2018Kaggle tokyo 2018
Kaggle tokyo 2018
 
Python advanced 3.the python std lib by example – algorithm
Python advanced 3.the python std lib by example – algorithmPython advanced 3.the python std lib by example – algorithm
Python advanced 3.the python std lib by example – algorithm
 
Standard template library
Standard template libraryStandard template library
Standard template library
 
Numpy and scipy
Numpy and scipyNumpy and scipy
Numpy and scipy
 
Php + MySql Optimization
Php + MySql OptimizationPhp + MySql Optimization
Php + MySql Optimization
 

Similar to Queues in data structures

cp264_lecture18_queue.ppt
cp264_lecture18_queue.pptcp264_lecture18_queue.ppt
cp264_lecture18_queue.ppt
ssuserff72e4
 

Similar to Queues in data structures (20)

Queues
Queues Queues
Queues
 
Stack and Queue.pptx
Stack and Queue.pptxStack and Queue.pptx
Stack and Queue.pptx
 
Chapter 7 ds
Chapter 7 dsChapter 7 ds
Chapter 7 ds
 
Stack and Queue by M.Gomathi Lecturer
Stack and Queue by M.Gomathi LecturerStack and Queue by M.Gomathi Lecturer
Stack and Queue by M.Gomathi Lecturer
 
Stack & Queue
Stack & QueueStack & Queue
Stack & Queue
 
Data Structure - Stacks
Data Structure - StacksData Structure - Stacks
Data Structure - Stacks
 
cp264_lecture18_queue.ppt
cp264_lecture18_queue.pptcp264_lecture18_queue.ppt
cp264_lecture18_queue.ppt
 
2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS2.1 STACK & QUEUE ADTS
2.1 STACK & QUEUE ADTS
 
Mca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queueMca ii dfs u-3 linklist,stack,queue
Mca ii dfs u-3 linklist,stack,queue
 
stacks and queues for public
stacks and queues for publicstacks and queues for public
stacks and queues for public
 
queue.pptx
queue.pptxqueue.pptx
queue.pptx
 
10994103.ppt
10994103.ppt10994103.ppt
10994103.ppt
 
Bca ii dfs u-2 linklist,stack,queue
Bca ii  dfs u-2 linklist,stack,queueBca ii  dfs u-2 linklist,stack,queue
Bca ii dfs u-2 linklist,stack,queue
 
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
 
Bsc cs ii dfs u-2 linklist,stack,queue
Bsc cs ii  dfs u-2 linklist,stack,queueBsc cs ii  dfs u-2 linklist,stack,queue
Bsc cs ii dfs u-2 linklist,stack,queue
 
Queue
QueueQueue
Queue
 
Difference between stack and queue
Difference between stack and queueDifference between stack and queue
Difference between stack and queue
 
Lesson 4 - Queue ADT.pdf
Lesson 4 - Queue ADT.pdfLesson 4 - Queue ADT.pdf
Lesson 4 - Queue ADT.pdf
 
stack & queue
stack & queuestack & queue
stack & queue
 
Stack.pptx
Stack.pptxStack.pptx
Stack.pptx
 

Recently uploaded

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Recently uploaded (20)

UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 

Queues in data structures

  • 1. QUEUES A U T H O R : T U S I F U E D I S O N
  • 2. DEFINITION • Queue is a linear data structure where elements are ordered in special fashion. i.e. FIFO(First IN First Out). Which means element inserted first to the queue will be removed first from the queue. In other words: queue is a list or collection with the restriction or constraints that insertion can be performed at one end (rear or tail) and deletion can be performed at other end(front or head) Author:Tusifu Edison
  • 3. ROLE OF THE QUEUES Queue is most often used in a scenario where there is a shared resource that’s supposed to serve some request but the resource can handle only one request at a time. A machine has a processor to process different programs(or to execute all instructions), and it has the ability to process one program at a time, so the processes are put in the queue. For the front process to be terminated Author:Tusifu Edison
  • 4. IMPLEMENTING QUEUES WITH LINKED LIST VS ARRAY Main disadvantages of implementing queues with arrays And linked list is the solution • By using array list you may store large memory which you will not use, • The array may get filled when you have other elements you want to insert That will cause to stop the insertion or create another big array and copy the first array And add the elements which you wantAuthor:Tusifu Edison
  • 5. OPERATIONS AVAILABLE WITH QUEUE • EnQueue(x) or push (x):insertion of element at the the rear or the tail of the queue. • Dequeue() or pop():deletion the element from the front or head of the queue. • Front() or peek():to look the element at the front • Is empty():check if the queue is empty or not Example: NB: all of this operations has the constant time or O(1) Author:Tusifu Edison
  • 8. ENQUEUE IMPLEMENTATION USING LINKED LIST (STRUCT+MAIN) Author:Tusifu Edison
  • 9. ENQUEUE AN ELEMENT IN THE QUEUE USING THE LINKED LIST Author:Tusifu Edison
  • 10. DEQUEUE AN ELEMENT FROM THE QUEUE USING THE LINKED LIST Author:Tusifu Edison