Priority Queue using HEAP. ( Using C in data structure )

21 views 15 slides May 29, 2024
Slide 1
Slide 1 of 15
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15

About This Presentation

Using in data structure


Slide Content

Priority Queue using HEAP
Register no.: 23CI037
Name. : POOJA SRI S
NANDHA ENGINEERING COLLEGE, AUTONOMOUS,ERODE - 52
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
(INTERNET OF THINGS)
Presented by

●Priority Queue is not strictly FIFO.
●Elements have priority.
●Insertion and deletion done based on the priority.
●The elements have higher priority that deleted first.

Now, for implementing the higher priority we have
2ways.
1.Smaller number higher priority (Min Heap)
2.Larger number higher priority ( Max Heap)

PRIORITY QUEUE (HEAP)

CHARACTERISTICS OF A PRIORITY QUEUE
●Every elements in a priority queue has some priority
associated with it.
●An element with the higher priority will be deleted before
the deletion of the lesser priority.
●If two elements in a priority queue have the same priority,
then will be arranged using the FIFO (FIRST IN AND FIRST OUT)
Principles

2 ways….
MIN heap :
Parent < Child
O(log n)
Heap is min
MAX heap :
Parent > Child
O(log n)
Heap is max

HEAP
●It is almost equal to
complete BINARY tree.
●Except for the last level
which can be partially
filled towards left.
●If it is filled with(or ends
with) right means it is not
heap.

Heap Data Structure

BASIC OPERATORS :
1.Enqueue() - Inserting an elements on the queue.
2.Dequeue() - Deleting an elements from the queue.
3.Peek() - Display the topmost element.
4.isfull() - Click if queue is full.
5.isempty() - Check if queue is empty.

ENQUEUE OPERATION IN QUEUE

Enqueue and Dequeue

TYPES OF PRIORITY QUEUE :
Ascending order priority queue:
Small to Great
Descending order priority queue:
Great to Small
●Ascending order
●Descending order
Tags