Priority Queue using HEAP. ( Using C in data structure )
21 views
15 slides
May 29, 2024
Slide 1 of 15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
About This Presentation
Using in data structure
Size: 713.97 KB
Language: en
Added: May 29, 2024
Slides: 15 pages
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