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

PPTX
Bubble Sort Algorithm Presentation
PPTX
PPTX
Quick sort
PPT
PDF
Sorting Algorithms
PPT
Knapsack problem
PPTX
Insertion sort
PPTX
The Stack And Recursion
Bubble Sort Algorithm Presentation
Quick sort
Sorting Algorithms
Knapsack problem
Insertion sort
The Stack And Recursion

What's hot (20)

PPTX
Stack and queue
PDF
Binary Search - Design & Analysis of Algorithms
PPTX
Queue ppt
PPTX
queue & its applications
PPSX
Stacks Implementation and Examples
PPTX
Data structure by Digvijay
PPTX
Insertion sort
PPT
Queue Data Structure
PPSX
Data Structure (Queue)
PPTX
Top down parsing
PPT
PPTX
Data structures
PPTX
My lectures circular queue
PPTX
AVL Tree in Data Structure
PPTX
Stack & Queue using Linked List in Data Structure
PPT
Breadth first search and depth first search
PPTX
Tree in data structure
PPTX
Data Structures - Lecture 9 [Stack & Queue using Linked List]
PDF
Algorithms Lecture 6: Searching Algorithms
PPT
Stack and queue
Binary Search - Design & Analysis of Algorithms
Queue ppt
queue & its applications
Stacks Implementation and Examples
Data structure by Digvijay
Insertion sort
Queue Data Structure
Data Structure (Queue)
Top down parsing
Data structures
My lectures circular queue
AVL Tree in Data Structure
Stack & Queue using Linked List in Data Structure
Breadth first search and depth first search
Tree in data structure
Data Structures - Lecture 9 [Stack & Queue using Linked List]
Algorithms Lecture 6: Searching Algorithms
Ad

Similar to Algorithm and Data Structure - Queue (20)

PPTX
Queue Data Structure
PDF
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
PPTX
QUEUE PPT BY KULJIT SINGH.pptx
PPTX
Unit-ii-Queue ADT.pptx
PPTX
Queue and its operations
PDF
PPTX
Basic Queue Operation in DataStructure.pptx
PDF
PDF
Algorithm and Data Structure - Stack
PDF
Stacks-and-Queues.pdf
PPTX
@Chapter 4 DSA Part II.pptx
PPT
Queue AS an ADT (Abstract Data Type)
PPTX
DS ppt1.pptx.c programing. Engineering. Data structure
PDF
PPTX
VCE Unit 03vv.pptx
PDF
5-Queue-----------------------------in c++
PPTX
CHAPTER 4 Learning QUEUE data structure.pptx
PPT
The Queue in Data structure and algorithm
PPTX
01-Introduction of DSA-1.pptx
PDF
4-Stack --------------------------------in C++.pdf
Queue Data Structure
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
QUEUE PPT BY KULJIT SINGH.pptx
Unit-ii-Queue ADT.pptx
Queue and its operations
Basic Queue Operation in DataStructure.pptx
Algorithm and Data Structure - Stack
Stacks-and-Queues.pdf
@Chapter 4 DSA Part II.pptx
Queue AS an ADT (Abstract Data Type)
DS ppt1.pptx.c programing. Engineering. Data structure
VCE Unit 03vv.pptx
5-Queue-----------------------------in c++
CHAPTER 4 Learning QUEUE data structure.pptx
The Queue in Data structure and algorithm
01-Introduction of DSA-1.pptx
4-Stack --------------------------------in C++.pdf
Ad

More from AndiNurkholis1 (20)

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

Recently uploaded (20)

PDF
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
PDF
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PDF
Chapter 2 Digital Image Fundamentals.pdf
PDF
Transforming Manufacturing operations through Intelligent Integrations
PDF
creating-agentic-ai-solutions-leveraging-aws.pdf
PDF
Modernizing your data center with Dell and AMD
PDF
Top Generative AI Tools for Patent Drafting in 2025.pdf
PDF
Sensors and Actuators in IoT Systems using pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Belt and Road Supply Chain Finance Blockchain Solution
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Dell Pro 14 Plus: Be better prepared for what’s coming
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
PDF
Google’s NotebookLM Unveils Video Overviews
PPTX
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
AI And Its Effect On The Evolving IT Sector In Australia - Elevate
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
GamePlan Trading System Review: Professional Trader's Honest Take
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Chapter 2 Digital Image Fundamentals.pdf
Transforming Manufacturing operations through Intelligent Integrations
creating-agentic-ai-solutions-leveraging-aws.pdf
Modernizing your data center with Dell and AMD
Top Generative AI Tools for Patent Drafting in 2025.pdf
Sensors and Actuators in IoT Systems using pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Belt and Road Supply Chain Finance Blockchain Solution
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Dell Pro 14 Plus: Be better prepared for what’s coming
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Google’s NotebookLM Unveils Video Overviews
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx

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