Groups
Groups
Sign in
Groups
Groups
Code fellow's playground
Conversations
About
Send feedback
Help
[程式]堆積樹Heap
17 views
Skip to first unread message
cpyi
unread,
Feb 17, 2013, 4:39:36 AM
2/17/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to code_fellow...@googlegroups.com
好久沒寫C囉,來一發。
Heap是一種樹,兩個分支的樹,然後每個父節點都比兩個子節點大。這個用途就是可以取出最大的數值(取出根節點就可以了),當然要實作取出一堆數中最大的數很容易實作,全部搜尋一次,找出最大的就好了,不過如果有n個數,那就需要n次工作,可是用Heap只要logn(底數二)次工作,在數目大的時候效率會高很多。
範例附檔。
heap.c
Reply all
Reply to author
Forward
0 new messages