Data Structures

Time Complexity of building a heap

Consider the following algorithm for building a Heap of an input array A.


    heapsize := size(A); 

    for i := floor(heapsize/2) downto 1 

        do HEAPIFY(A, i); 

    end for 

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.

Recent Comments


For any feedback,email us at

Report a Bug

For any report or bug,email us at