對 n 個元素以 bottom-up 方式建立 max-heap,時間複雜度為何?
參考答案與解析
各層 heapify 成本加總為等比級數收斂,總計 O(n);逐一 insert 才是 O(n log n)。