KEMBAR78
Priority Queue using HEAP. ( Using C in data structure ) | PDF
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
Priority Queue using HEAP.  ( Using C in data structure )

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

  • 1.
    Priority Queue usingHEAP Register no.: 23CI037 Name. : POOJA SRI S NANDHA ENGINEERING COLLEGE, AUTONOMOUS,ERODE - 52 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING (INTERNET OF THINGS) Presented by
  • 2.
    ● Priority Queueis 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)
  • 3.
    CHARACTERISTICS OF APRIORITY 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
  • 4.
    2 ways…. MIN heap: Parent < Child O(log n) Heap is min MAX heap : Parent > Child O(log n) Heap is max
  • 7.
    HEAP ● It isalmost 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.
  • 8.
  • 9.
    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.
  • 10.
  • 11.
  • 14.
    TYPES OF PRIORITYQUEUE : Ascending order priority queue: Small to Great Descending order priority queue: Great to Small ● Ascending order ● Descending order