算法导论书上有个练习,让证明n个元素的第2个最小的元素可以用n + ceil(lg n) - 2次比较找出来,给的提示只是:把最小的也找出来。
我想了好久,终于出来了。思路是:n-1次比较找出最小,然后再用ceil(lg n)-1次比较就找到第2个最小。具体见这一页。
This entry was posted
on Monday, January 8th, 2007 at 11:56 pm and is filed under Algorithm.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
O(n)就能做的
oo,弄错了