07 - Heaps and Priority Queues
07 - Heaps and Priority Queues
Queues
Jollibee L. Lacsama
Instructor
Heap Data Structure
- Is a data structure used to manage information
- Sometimes called ‘binary heaps’
- Nearly complete binary tree
Heap Data Structure
• always greater than its child node/s and the key of the root
node is the largest among all other nodes. This property is
also called max heap property.
• always smaller than the child node/s and the key of the root
node is the smallest among all other nodes. This property is
also called min heap property.
Max Heap
node 15
left(3) = 2*3
= 6 (index 6, node 12)
right(3) = 2*3 + 1
= 7 (index 7, node 13)
2. Deleting an Element
from the Priority Queue