Consider the following algorithm for Time Complexity of building a heap of an input array A.

[pastacode lang=”c” manual=”BUILD-HEAP(A)%20%0A%20%20%20%20heapsize%20%3A%3D%20size(A)%3B%20%0A%20%20%20%20for%20i%20%3A%3D%20floor(heapsize%2F2)%20downto%201%20%0A%20%20%20%20%20%20%20%20do%20HEAPIFY(A%2C%20i)%3B%20%0A%20%20%20%20end%20for%20%0AEND” message=”” highlight=”” provider=”manual”/] [ad type=”banner”]

What is the worst case time complexity of the above algo?
Although the worst case complexity looks like O(nLogn), upper bound of time complexity is O(n). See following links for the proof of time complexity.

Categorized in: