Data Structures and Algorithms Queue and Priority Queue

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

QUEUE

DATA STRUCTURE
WHAT?
Linear Data Structure
that implements
Abstract Data Type
(ADT), by following the
FIFO (First In, First
Out) principle
CHARACTERISTICS OF QUEUE

 Insertion parts: the


Front/Head and the
Rear/Tail/Back.

 The Back is where the


items are inserted and the
Front is the part of the
queue where items are
removed/deleted.
PRACTICAL APPLICATION
Significant place in the realm of IT education
1] CALL CENTER PHONE SYSTEM
2] TRAFFIC SYSTEM
3] PRINT QUEUE
4] MEMORY/CPU/IO MANAGEMENT
COMMON
OPERATIONS
QUEUE :: The Queue Functions
QUEUE OPERATIONS
Enqueue: Adds an item from the back of the queue
Dequeue:Removes an item from the front of the queue
IsEmpty: Check if the queue is empty
IsFull: Check if the queue is full
Peek: Returns the value of the item in front of the queue without
dequeuing (removing) the item
Count: Returns the total number of elements in the queue
Change: Changes the element at the given position
Display: Prints all the items in the queue
TYPES OF QUEUE
01 02 03
SIMPLE PRIORITY CIRCULAR
<CONVENTIONAL> <PRIORITY VALUE> <CYCLICAL>
SIMPLE Queue

In a simple queue, insertion takes place at


the rear and removal occurs at the front. It
strictly follows the FIFO rule.
WORKING OF SIMPLE QUEUE
SIMPLE QUEUEING
Circular Queue

The Circular Queue is similar to a Linear


Queue in the sense that it follows the FIFO
(First In First Out) principle but differs in the
fact that the last position is connected to
the first position, replicating a circle.
WORKING OF CIRCULAR QUEUE
CIRCULAR QUEUEING [1] >> LINEAR PERSPECTIVE
CIRCULAR QUEUEING [2]
CIRCULAR QUEUE >> CYCLIC PERSPECTIVE
PRIORITY Queue

A priority queue is a type of queue that


arranges elements based on their priority
values. Elements with higher priority values
are typically retrieved before elements with
lower priority values.
TYPES OF PRIORITY QUEUE

ASCENDING DESCENDING
In ascending order priority In descending order priority
queue, a lower priority queue, a higher priority
number is given as a higher number is given as a higher
priority in a priority priority in a priority
WORKING OF PRIORITY QUEUE

Insert 7, 2, 45, 32, and 12 in a priority queue

You might also like