SlideShare a Scribd company logo
8
Most read
15
Most read
17
Most read
Algorithm and
Data Structure
Andi Nurkholis, S.Kom, M.Kom
Study Program of Informatics
Faculty of Engineering and Computer Science
SY. 2020-2021
April 19, 2021
2
5 Queue
3
What is Queue?
Like Stack, Queue is a linear structure which follows a
particular order in which the operations are
performed. The order is First In First Out (FIFO). A
good example of queue is any queue of consumers
for a resource where the consumer that came first is
served first.
4
Illustration
5
Queue VS Stack
The difference between stacks and queues is in removing. In a
stack we remove the item the most recently added; in a queue,
we remove the item the least recently added
6
Queue
Operations
1) Enqueue
2) Dequeue
3) Front
4) Rear
7
Enqueue
Enqueue: Adds an item in the stack. If the stack is full, then it is
said to be an Overflow condition.
Steps of Enqueue
Step 1 − Check if the queue is full.
Step 2 − If the queue is full, produce overflow error
and exit.
Step 3 − If the queue is not full, increment rear
pointer to point the next empty space.
Step 4 − Add data element to the queue location,
where the rear is pointing.
Step 5 − return success.
8
9
Enqueue Algorithm
begin procedure enqueue(data)
if queue is full
return overflow
endif
rear ← rear + 1
queue[rear] ← data
return true
end procedure
Dequeue
Dequeue: Removes an item from the queue. The items are
popped in the same order in which they are pushed. If the
queue is empty, then it is said to be an Underflow condition.
10
Steps of Dequeue
Step 1 − Check if the queue is empty.
Step 2 − If the queue is empty, produce underflow
error and exit.
Step 3 − If the queue is not empty, access the data
where front is pointing.
Step 4 − Increment front pointer to point to the next
available data element.
Step 5 − Return success.
11
Dequeue Algorithm
begin procedure dequeue
if queue is empty
return underflow
end if
data = queue[front]
front ← front + 1
return true
end procedure
12
Front
Front: Get the front item from queue.
13
Front Algorithm:
begin procedure front
return queue[top]
end procedure
Rear
Rear: Get the last item from
queue.
Rear Algorithm:
begin procedure rear
return queue[last]
end procedure
14
Working of Queue
This abstract data type​ can be implemented in C in
multiple ways. One such way is by using an array.
Pro of using an array:
Easy to implement.
Con of using an array:
Static Data Structure, fixed size.
15
Queue Application
1. CPU scheduling, Disk Scheduling
2. When data is transferred asynchronously between two
processes.The queue is used for synchronization. For example:
IO Buffers, pipes, file IO, etc
3. Handling of interrupts in real-time systems.
4. Call Center phone systems use Queues to hold people calling
them in order.
16
Thank You, Next …
Searching
April 19, 2021
Andi Nurkholis, S.Kom, M.Kom
Study Program of Informatics
Faculty of Engineering and Computer Science
SY. 2020-2021

More Related Content

What's hot (20)

PPTX
Circular linked list
sajinis3
 
PPTX
My lectures circular queue
Senthil Kumar
 
PPT
Queue Data Structure
Lovely Professional University
 
PPT
Stack a Data Structure
ForwardBlog Enewzletter
 
PPTX
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
PDF
linked lists in data structures
DurgaDeviCbit
 
PPTX
Queues
Ashim Lamichhane
 
PPT
Queue Data Structure
Zidny Nafan
 
PPT
Stacks
sweta dargad
 
PPSX
Data Structure (Queue)
Adam Mukharil Bachtiar
 
PPT
Queue
Nabeel Ahsen
 
PPTX
Priority Queue in Data Structure
Meghaj Mallick
 
PPT
1.5 binary search tree
Krish_ver2
 
PDF
Stack
Zaid Shabbir
 
PPT
Data Structure and Algorithms Binary Search Tree
ManishPrajapati78
 
PPT
Pattern matching
shravs_188
 
PPT
Circular linked list
chauhankapil
 
PPTX
Introduction to stack
vaibhav2910
 
PDF
Queues
Hareem Aslam
 
PPTX
Data structure , stack , queue
Rajkiran Nadar
 
Circular linked list
sajinis3
 
My lectures circular queue
Senthil Kumar
 
Queue Data Structure
Lovely Professional University
 
Stack a Data Structure
ForwardBlog Enewzletter
 
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
linked lists in data structures
DurgaDeviCbit
 
Queue Data Structure
Zidny Nafan
 
Stacks
sweta dargad
 
Data Structure (Queue)
Adam Mukharil Bachtiar
 
Priority Queue in Data Structure
Meghaj Mallick
 
1.5 binary search tree
Krish_ver2
 
Data Structure and Algorithms Binary Search Tree
ManishPrajapati78
 
Pattern matching
shravs_188
 
Circular linked list
chauhankapil
 
Introduction to stack
vaibhav2910
 
Queues
Hareem Aslam
 
Data structure , stack , queue
Rajkiran Nadar
 

Similar to Algorithm and Data Structure - Queue (20)

PPTX
Queue and its operations
V.V.Vanniaperumal College for Women
 
PDF
Queues
maamir farooq
 
PPTX
Queues
nidhisatija1
 
PPTX
queue.pptx
Dr.Shweta
 
PDF
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
playstore9ha
 
PDF
Queue
pooja kumari
 
PPTX
@Chapter 4 DSA Part II.pptx
NuraMohamed9
 
PPTX
Queue ppt
SouravKumar328
 
PPTX
Queue
Abdur Rehman
 
PPTX
QUEUE PPT BY KULJIT SINGH.pptx
TajBir4
 
PPTX
queueppt-191018053228 (1).pptx
MeghaKulkarni27
 
PPTX
Stack and Queue.pptx
Ddushb
 
PPTX
Stack & Queue
Hasan Mahadi Riaz
 
PPTX
DS ppt1.pptx.c programing. Engineering. Data structure
dibyajyotijena05
 
PPT
QUEUE OPERATIONS in DATASTRUCTURE AND ALGORITHMS
Usha P
 
PPTX
Queue data structures and operation on data structures
muskans14
 
PPTX
Data structures
naveeth babu
 
DOCX
Queue - Operations and Implementations
Sagacious IT Solution
 
PPTX
Queue - Data Structure - Notes
Omprakash Chauhan
 
PPTX
queue.pptx
NSudhaEccs
 
Queue and its operations
V.V.Vanniaperumal College for Women
 
Queues
nidhisatija1
 
queue.pptx
Dr.Shweta
 
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
playstore9ha
 
@Chapter 4 DSA Part II.pptx
NuraMohamed9
 
Queue ppt
SouravKumar328
 
QUEUE PPT BY KULJIT SINGH.pptx
TajBir4
 
queueppt-191018053228 (1).pptx
MeghaKulkarni27
 
Stack and Queue.pptx
Ddushb
 
Stack & Queue
Hasan Mahadi Riaz
 
DS ppt1.pptx.c programing. Engineering. Data structure
dibyajyotijena05
 
QUEUE OPERATIONS in DATASTRUCTURE AND ALGORITHMS
Usha P
 
Queue data structures and operation on data structures
muskans14
 
Data structures
naveeth babu
 
Queue - Operations and Implementations
Sagacious IT Solution
 
Queue - Data Structure - Notes
Omprakash Chauhan
 
queue.pptx
NSudhaEccs
 
Ad

More from AndiNurkholis1 (20)

PDF
Technopreneurship - 9 Analisis Biaya dan Keuangan
AndiNurkholis1
 
PDF
Pengantar Bisnis - 14 Manajemen Keuangan
AndiNurkholis1
 
PDF
Pengantar Bisnis - 13 Manajemen Operasi
AndiNurkholis1
 
PDF
Pengantar Bisnis - 12 Kebijakan Harga
AndiNurkholis1
 
PDF
Pengantar Bisnis - 11 Kebijakan Distribusi
AndiNurkholis1
 
PDF
Technopreneurship - 8 Manajemen Sumber Daya Manusia
AndiNurkholis1
 
PDF
Pengantar Bisnis - 10 Kebijakan Produk
AndiNurkholis1
 
PDF
Technopreneurship - 7 Manajemen Pemasaran dan Operasional Bisnis
AndiNurkholis1
 
PDF
Pengantar Bisnis - 9 Manajemen Pemasaran
AndiNurkholis1
 
PDF
Technopreneurship - 6 Business Plan
AndiNurkholis1
 
PDF
Pengantar Bisnis - 8 Kepemimpinan
AndiNurkholis1
 
PDF
Technopreneurship - 5 Model Bisnis
AndiNurkholis1
 
PDF
Technopreneurship - 4 Studi Kelayakan Usaha
AndiNurkholis1
 
PDF
Pengantar Bisnis - 7 Motivasi Kerja
AndiNurkholis1
 
PDF
Pengantar Bisnis - 6 Manajemen Sumber Daya Manusia
AndiNurkholis1
 
PDF
Pengantar Bisnis - 5 Pengelolaan & Pengorganisasian Bisnis
AndiNurkholis1
 
PDF
Technopreneurship - 3 Ide dan Prinsip Bisnis
AndiNurkholis1
 
PDF
Pengantar Bisnis - 4 Bentuk Organisasi Bisnis
AndiNurkholis1
 
PDF
Technopreneurship - 2 Pengantar Technopreneurship
AndiNurkholis1
 
PDF
Pengantar Bisnis - 3 Globalisasi Ekonomi & Bisnis Internasional
AndiNurkholis1
 
Technopreneurship - 9 Analisis Biaya dan Keuangan
AndiNurkholis1
 
Pengantar Bisnis - 14 Manajemen Keuangan
AndiNurkholis1
 
Pengantar Bisnis - 13 Manajemen Operasi
AndiNurkholis1
 
Pengantar Bisnis - 12 Kebijakan Harga
AndiNurkholis1
 
Pengantar Bisnis - 11 Kebijakan Distribusi
AndiNurkholis1
 
Technopreneurship - 8 Manajemen Sumber Daya Manusia
AndiNurkholis1
 
Pengantar Bisnis - 10 Kebijakan Produk
AndiNurkholis1
 
Technopreneurship - 7 Manajemen Pemasaran dan Operasional Bisnis
AndiNurkholis1
 
Pengantar Bisnis - 9 Manajemen Pemasaran
AndiNurkholis1
 
Technopreneurship - 6 Business Plan
AndiNurkholis1
 
Pengantar Bisnis - 8 Kepemimpinan
AndiNurkholis1
 
Technopreneurship - 5 Model Bisnis
AndiNurkholis1
 
Technopreneurship - 4 Studi Kelayakan Usaha
AndiNurkholis1
 
Pengantar Bisnis - 7 Motivasi Kerja
AndiNurkholis1
 
Pengantar Bisnis - 6 Manajemen Sumber Daya Manusia
AndiNurkholis1
 
Pengantar Bisnis - 5 Pengelolaan & Pengorganisasian Bisnis
AndiNurkholis1
 
Technopreneurship - 3 Ide dan Prinsip Bisnis
AndiNurkholis1
 
Pengantar Bisnis - 4 Bentuk Organisasi Bisnis
AndiNurkholis1
 
Technopreneurship - 2 Pengantar Technopreneurship
AndiNurkholis1
 
Pengantar Bisnis - 3 Globalisasi Ekonomi & Bisnis Internasional
AndiNurkholis1
 
Ad

Recently uploaded (20)

PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 

Algorithm and Data Structure - Queue

  • 1. Algorithm and Data Structure Andi Nurkholis, S.Kom, M.Kom Study Program of Informatics Faculty of Engineering and Computer Science SY. 2020-2021 April 19, 2021
  • 3. 3 What is Queue? Like Stack, Queue is a linear structure which follows a particular order in which the operations are performed. The order is First In First Out (FIFO). A good example of queue is any queue of consumers for a resource where the consumer that came first is served first.
  • 5. 5 Queue VS Stack The difference between stacks and queues is in removing. In a stack we remove the item the most recently added; in a queue, we remove the item the least recently added
  • 7. 7 Enqueue Enqueue: Adds an item in the stack. If the stack is full, then it is said to be an Overflow condition.
  • 8. Steps of Enqueue Step 1 − Check if the queue is full. Step 2 − If the queue is full, produce overflow error and exit. Step 3 − If the queue is not full, increment rear pointer to point the next empty space. Step 4 − Add data element to the queue location, where the rear is pointing. Step 5 − return success. 8
  • 9. 9 Enqueue Algorithm begin procedure enqueue(data) if queue is full return overflow endif rear ← rear + 1 queue[rear] ← data return true end procedure
  • 10. Dequeue Dequeue: Removes an item from the queue. The items are popped in the same order in which they are pushed. If the queue is empty, then it is said to be an Underflow condition. 10
  • 11. Steps of Dequeue Step 1 − Check if the queue is empty. Step 2 − If the queue is empty, produce underflow error and exit. Step 3 − If the queue is not empty, access the data where front is pointing. Step 4 − Increment front pointer to point to the next available data element. Step 5 − Return success. 11
  • 12. Dequeue Algorithm begin procedure dequeue if queue is empty return underflow end if data = queue[front] front ← front + 1 return true end procedure 12
  • 13. Front Front: Get the front item from queue. 13 Front Algorithm: begin procedure front return queue[top] end procedure
  • 14. Rear Rear: Get the last item from queue. Rear Algorithm: begin procedure rear return queue[last] end procedure 14
  • 15. Working of Queue This abstract data type​ can be implemented in C in multiple ways. One such way is by using an array. Pro of using an array: Easy to implement. Con of using an array: Static Data Structure, fixed size. 15
  • 16. Queue Application 1. CPU scheduling, Disk Scheduling 2. When data is transferred asynchronously between two processes.The queue is used for synchronization. For example: IO Buffers, pipes, file IO, etc 3. Handling of interrupts in real-time systems. 4. Call Center phone systems use Queues to hold people calling them in order. 16
  • 17. Thank You, Next … Searching April 19, 2021 Andi Nurkholis, S.Kom, M.Kom Study Program of Informatics Faculty of Engineering and Computer Science SY. 2020-2021