For creating a Min heap or a Max Heap of n elements, time taken would be O(nlogn) for creating a heap. Because, every insertion takes O(logn) time and hence n elements would take O(nlogn) time
But in many places it is written that the creation of a heap can be optimized to O(n) time i.e. a linear time?But it is not clearly explained how?
The optimal method doesn’t need logn time for inserting a node.
Source: http://en.wikipedia.org/wiki/Binary_heap#Building_a_heap