Lecture 05
Lecture 05
Heaps are the data structure you want to use when you want to
be able to access the maximum or minimum element very
quickly
70 50 40 45 35 39 16 10 9
Data Insertion in Heap
15 5 20 1 17 10 30
All leaves are root, no need to heapify
Only apply to no leave nodes the method heapify
Apply from right to left
Start from largest index except from leaves
In complete binary tree non leaf nodes will be
from floor(n/2) +1 ---> n
In example index 4-7 will be leave nodes
Heapify Assignment/HW