I know that the running time for BUILD-MAX-HEAP in heap sort is O(n)
. But, if we have an array that already sorted in a decreasing order, why do we still have O(n)
for the running time of BUILD-MAX-HEAP?
Isn't it supposed to be something like O(1)
? It's already sorted from the maximum value to the minimum value, so we do not need MAX-HEAPIFY.
Is my understanding correct? Could someone please explain it to me?