SlideShare a Scribd company logo
Queue
Adam M.B.
DEFINITION

Queue
• queue is data structure whose its
elemen can be added in the last
element and taken only from the first
element.
• Known as FIFO (First In First Out).
Components of Queue
• Front is a variable which refers to first position
in queue.
• Rear is a variable which refers to last position in
queue.
• Element is component which has data.
• MaxQueue is variable that describes
maximum number of elements in a queue.
DECLARATION

Declaration as Array
Kamus:
Const
MaxQueue = value {value is integer number}
Type
NamaQueue = array [1..MaxQueue] of tipedata
Queue : NamaQueue
Front, Rear : integer {pointer of Queue}
Declaration as Array
Kamus:
Const
MaxQueue = 4
Type
ArrayQueue = array [1..MaxQueue] of integer
Queue : ArrayQueue
Front, Rear : integer {pointer of Queue}
Declaration as List
Kamus:
Type
NamaPointer = ↑Queue
Queue = Record
< MedanData : TipeData,
MedanSambungan : NamaPointer >
EndRecord
Front, Rear : NamaPointer {pointer of queue}
Declaration as List
Kamus:
Type
Point = ↑Queue
Queue = Record
< Angka : integer,
Next : Point >
EndRecord
Front, Rear : Point {pointer of queue}
OPERATION

Operation
• Initialization
• Empty Operation
• Full Operation (array)/One Node
Operation (Linked List)
• Enqueue
• Dequeue
Main Operation
Enqueue
Queue
Take data from
element in
queue.
Dequeue
Add data to
element in
queue.
Kinds of Operation
• Queue Operation in linear array form
• Queue Operation in Linked list form
• Queue Operation in circular array form
QUEUE OPERATION
IN ARRAY FORM

Operation that give a initial value for front
and rear pointer in queue with the
following rules:
• Give 0 if the first element starts from 1
• Give -1 if the first element starts from 0
Initialization
Operation that returns true if the rear
pointer have 0 or -1 as its value (depend
on initialization) or returns false to the
contrary.
Empty Operation
Operation that returns true if rear has
reached maximum array or maximum
array -1 (depend on initialization) or
returns false if top is not equal to
maximum array.
Full Operation
Steps in enqueue operation:
• Queue can be added when it’s not full
• If queue is empty then front and rear is
added by 1. For the contrary, rear is added
by 1.
• Queue element, which was refered by rear
pointer, is filled with new data.
Enqueue
Enqueue
Enqueue(Front,Rear,Queue,8)
Enqueue(Front,Rear,Queue,3)
Enqueue(Front,Rear,Queue,5)
Enqueue(Front,Rear,Queue,7)
“Queue is full”
Queue
1 2 3 40
front rear
3 5 8 7
Enqueue(Front,Rear,Queue,2)
Steps in dequeue operation:
• Queue can be dequeue when its elements is
not empty.
• After first element is taken out from queue
then second element in queue will be shifted
into first element and so on.
• Substract the rear pointer with 1.
Dequeue
Dequeue
Queue
1 2 3 40
front rear
3 5 8 7
Dequeue(Front,Rear,Queue,Item)
“Queue is Empty”
Dequeue(Front,Rear,Queue,Item)
Dequeue(Front,Rear,Queue,Item)
Dequeue(Front,Rear,Queue,Item)
Dequeue(Front,Rear,Queue,Item)
Item
35 8 58 7 877 7
QUEUE OPERATION
IN LINKED LIST FORM

Prepare queue by giving null value to
the front and rear pointer in queue.
Initialization
Operation that returns true if the rear
pointer is null or returns false to the
contrary.
Empty Operation
Operation that returns true if rear and
front refer to same node (queue only has
one node) or returns false to the
contrary.
One Node Operation
Steps of enqueue operation in linked list
form is similar with back insertion.
Enqueue
Enqueue
 Enqueue(Front,Rear,8)
baru 8
Front
Queue is empty
Rear
Enqueue
 Enqueue(Front,Rear,3)
baru 3
8
Front
Queue isn’t empty
Rear
Enqueue
 Enqueue(Front,Rear,5)
baru 5
8
Front
Queue isn’t empty
Rear
3
Steps of dequeue operation in linked list
form is similar with front deletion.
Dequeue
Dequeue
 Dequeue(Front,Rear,Item)
58
Front Rear
3
{Queue > One node}
Item
Phapus
Dequeue
 Dequeue(Front,Rear,Item)
5
Front
3
{Queue > one node}
Item
Phapus Rear
Dequeue
 Dequeue(Front,Rear,Item)
5
Front
{Queue = one node}
Item
Phapus
Rear Front Rear
QUEUE OPERATION
IN CIRCULAR ARRAY
FORM

Steps in enqueue operation:
• Queue can be added when it’s not full
• If queue is empty then front and rear is added by
1. If it isn’t empty then rear is added by 1 but if
rear is at maximum queue then rear = 1.
• Queue element, which was refered by rear pointer,
is filled with new data.
Enqueue
Steps in dequeue operation:
• Queue can be dequeue when its elements is
not empty.
• If it isn’t empty then front is added by 1.
• If front is at maximum queue then front = 1.
Dequeue
Enqueue and Dequeue
Enqueue(Front,Rear,Queue,8)
Enqueue(Front,Rear,Queue,3)
Enqueue(Front,Rear,Queue,5)
Dequeue(Front,Rear,Queue,item)
Enqueue(Front,Rear,Queue,7)
“Queue is full”
Queue
1 2 3 40
front rear
8 3 5 7
Enqueue(Front,Rear,Queue,2)
Enqueue(Front,Rear,Queue,9)
2
Dequeue(Front,Rear,Queue,item)
8
Enqueue(Front,Rear,Queue,12)Item
3
9
Do the task 6.46 and 6.48 in page 212 at
Data Structures book, seymour.
Exercise
Contact Person:
Adam Mukharil Bachtiar
Informatics Engineering UNIKOM
Jalan Dipati Ukur Nomor. 112-114 Bandung 40132
Email: adfbipotter@gmail.com
Blog: http://adfbipotter.wordpress.com
Copyright © Adam Mukharil Bachtiar 2012

More Related Content

PPTX
Queue - Data Structure - Notes
PPTX
Queues in C++
PPTX
Queue and its operations
PPTX
PPTX
Queue in Data Structure
PPTX
Deque and its applications
PPTX
queue & its applications
PPT
Queue data structure
Queue - Data Structure - Notes
Queues in C++
Queue and its operations
Queue in Data Structure
Deque and its applications
queue & its applications
Queue data structure

What's hot (20)

PPTX
Queue ppt
PPTX
Doubly Linked List
PPTX
Linked list
PPTX
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
PPTX
STACKS IN DATASTRUCTURE
PPTX
PPTX
sorting and its types
PPTX
stack & queue
PPTX
Priority Queue in Data Structure
PPTX
Data structure - Graph
PPTX
Introduction to data structure ppt
PPTX
Data structure & its types
PPTX
Binary Search Tree
PPTX
Stack and Queue
PPTX
linked list in data structure
PPTX
Arrays In C++
PDF
PPTX
heap Sort Algorithm
PPTX
Data Structures - Lecture 9 [Stack & Queue using Linked List]
PPT
Bubble sort
Queue ppt
Doubly Linked List
Linked list
Application of Stack For Expression Evaluation by Prakash Zodge DSY 41.pptx
STACKS IN DATASTRUCTURE
sorting and its types
stack & queue
Priority Queue in Data Structure
Data structure - Graph
Introduction to data structure ppt
Data structure & its types
Binary Search Tree
Stack and Queue
linked list in data structure
Arrays In C++
heap Sort Algorithm
Data Structures - Lecture 9 [Stack & Queue using Linked List]
Bubble sort
Ad

Viewers also liked (20)

PDF
Queue as data_structure
PPT
Queue in Data Structure
PPT
Queue Data Structure
PDF
PPTX
Queue Data Structure (w/ php egs)
PPTX
Presentation on queue
PPTX
Ppt presentation of queues
PPT
Notes DATA STRUCTURE - queue
PDF
Queues
PPT
Materi Struktur data QUEUE
PPT
Queue data structure
PPTX
PPTX
المحاضرة الثامنة: تراكيب البيانات الطابور
PPT
358 33 powerpoint-slides_9-stacks-queues_chapter-9
PPTX
Stack and queue
PPTX
Data Structure -List Stack Queue
PPTX
5. Queue - Data Structures using C++ by Varsha Patil
PPTX
Data structures and algorithms
PDF
Ruby on Redis
ODT
Rituales a la diosa Hécate
Queue as data_structure
Queue in Data Structure
Queue Data Structure
Queue Data Structure (w/ php egs)
Presentation on queue
Ppt presentation of queues
Notes DATA STRUCTURE - queue
Queues
Materi Struktur data QUEUE
Queue data structure
المحاضرة الثامنة: تراكيب البيانات الطابور
358 33 powerpoint-slides_9-stacks-queues_chapter-9
Stack and queue
Data Structure -List Stack Queue
5. Queue - Data Structures using C++ by Varsha Patil
Data structures and algorithms
Ruby on Redis
Rituales a la diosa Hécate
Ad

Similar to Data Structure (Queue) (20)

PPTX
queue.pptx
PPT
Lec-07 Queues.ppt queues introduction to queue
PDF
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
PPTX
Basic Queue Operation in DataStructure.pptx
PPTX
Queues_0748555555555555555555555526.pptx
PPTX
DS ppt1.pptx.c programing. Engineering. Data structure
PPTX
@Chapter 4 DSA Part II.pptx
PPTX
PPTX
Data Structures - Lecture 6 [queues]
PPTX
PDF
PDF
Polynomialmotilalanehrunationalinstitute.pdf
PPT
Lect 17-18 Zaheer Abbas
PPT
Queues in C++ detailed explanation and examples .ppt
PPTX
PPTX
Queue data structures and operation on data structures
PDF
PPTX
Queue Implementation Using Array & Linked List
PDF
queue.pptx
Lec-07 Queues.ppt queues introduction to queue
Lab 07 (2).pdfbdvdyve dhdysbsnjsnsvdvydbdns
Basic Queue Operation in DataStructure.pptx
Queues_0748555555555555555555555526.pptx
DS ppt1.pptx.c programing. Engineering. Data structure
@Chapter 4 DSA Part II.pptx
Data Structures - Lecture 6 [queues]
Polynomialmotilalanehrunationalinstitute.pdf
Lect 17-18 Zaheer Abbas
Queues in C++ detailed explanation and examples .ppt
Queue data structures and operation on data structures
Queue Implementation Using Array & Linked List

More from Adam Mukharil Bachtiar (20)

PDF
Materi 8 - Data Mining Association Rule.pdf
PDF
Clean Code - Formatting Code
PDF
Clean Code - Clean Comments
PDF
PDF
Clean Code and Design Pattern - Meaningful Names
PDF
Model Driven Software Development
PDF
Scrum: How to Implement
PDF
Pengujian Perangkat Lunak
PDF
Data Mining Clustering
PPTX
Data Mining Klasifikasi (Updated 30 Desember 2020)
PDF
Analisis Algoritma - Strategi Algoritma Dynamic Programming
PDF
Analisis Algoritma - Strategi Algoritma Divide and Conquer
PDF
Analisis Algoritma - Strategi Algoritma Greedy
PDF
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
PDF
Analisis Algoritma - Strategi Algoritma Brute Force
PDF
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
PDF
Analisis Algoritma - Teorema Notasi Asimptotik
PDF
Analisis Algoritma - Notasi Asimptotik
PDF
Activity Diagram
PDF
UML dan Use Case View
Materi 8 - Data Mining Association Rule.pdf
Clean Code - Formatting Code
Clean Code - Clean Comments
Clean Code and Design Pattern - Meaningful Names
Model Driven Software Development
Scrum: How to Implement
Pengujian Perangkat Lunak
Data Mining Clustering
Data Mining Klasifikasi (Updated 30 Desember 2020)
Analisis Algoritma - Strategi Algoritma Dynamic Programming
Analisis Algoritma - Strategi Algoritma Divide and Conquer
Analisis Algoritma - Strategi Algoritma Greedy
Analisis Algoritma - Penerapan Strategi Algoritma Brute Force
Analisis Algoritma - Strategi Algoritma Brute Force
Analisis Algoritma - Kelas-kelas Dasar Efisiensi Algoritma
Analisis Algoritma - Teorema Notasi Asimptotik
Analisis Algoritma - Notasi Asimptotik
Activity Diagram
UML dan Use Case View

Recently uploaded (20)

PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
System and Network Administraation Chapter 3
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Transform Your Business with a Software ERP System
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Nekopoi APK 2025 free lastest update
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
medical staffing services at VALiNTRY
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
Odoo Companies in India – Driving Business Transformation.pdf
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Odoo POS Development Services by CandidRoot Solutions
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Upgrade and Innovation Strategies for SAP ERP Customers
System and Network Administraation Chapter 3
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Transform Your Business with a Software ERP System
Navsoft: AI-Powered Business Solutions & Custom Software Development
Nekopoi APK 2025 free lastest update
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
medical staffing services at VALiNTRY
CHAPTER 2 - PM Management and IT Context
VVF-Customer-Presentation2025-Ver1.9.pptx
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
ISO 45001 Occupational Health and Safety Management System
Odoo Companies in India – Driving Business Transformation.pdf

Data Structure (Queue)