Complexity Analysis
We'll cover the following...
Building the heap
As mentioned in the previous lesson, the time complexity of building a heap is . This is not obvious right away so let’s analyse the algorithm.
The entire building of the heap can be expressed as heapify events. Each heapify event take time where is the height of the tree.
When I say heapify in this lesson, I mean the top to bottom heapify, the same can be proved for the bottom to up heapify as well.
Each heapify event can be provided with a tighter upper bound than ...
Access this course and 1400+ top-rated courses and projects.