作者VB2005 (DaiJouBu)
看板Grad-ProbAsk
標題[理工] min heap 問題
時間Tue Aug 7 21:46:25 2012
(B) in the worst case, initializing a min heap with
n elements takes Θ(logN)time
(C) in the average case, initializing a min heap with
n elements takes Θ(logN)time
這兩個是錯的。有人可以說一下,錯在哪嗎?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.118.254.246
→ wsx02:buttom up O(n) 08/07 21:47
→ VB2005:可詳細一點嗎? 08/07 21:56
→ wsx02:建heap絕對不可能只花lgn 不然就太神了XD 08/07 22:12
→ cutemiller:先建complete binary tree 然後,由最後一個parent 08/07 23:00
→ cutemiller:往上調整,所以 O(n) 08/07 23:00
→ VB2005:知道了。謝謝 08/07 23:09