HeapSort 中已经降序排列的数组的时间复杂度

Time complexity of already-descending-sorted array in HeapSort

考虑一个已经按降序排序的数组 A[n]。堆已经建立。现在考虑我们将 A[1](数组索引从 1 开始)与 A[heap.size] 交换的循环。这是伪代码:

Build-Max-Heap(A) //Already done
while (i > 0) {

     swap(A[1] with A[heap_size]
     heap_size = heap_size - 1
     Max-Heapify(A,1) //Takes lg(A.heap_size) time to float the 1st element down to it's respective position

} 

我们在元素 1 上调用 Max-Heapify 以恢复堆 属性,方法是允许它向下浮动到适当的位置。我们知道 Max-Heapify 将花费 clg(n) 时间。所以,循环不应该花费 c(lg (n) + lg (n-1) + .... + lg(1) ) = Theta(log(n)) 时间而不是 jut Theta (n*lg(n))?因为每次迭代堆大小都在减小?

n..1的对数和不是log(n)而是nlogn(看斯特林公式)

从任意数组构建经典堆是 O(n) 过程 - 而不是 O(nlogn)