堆
ngncmh
这个作者很懒,什么都没留下…
展开
-
关于动态规划的单调队列优化
POJ2373:Dividing the Path描述Farmer John's cows have discovered that the clover growing along the ridge of the hill in his field is particularly good. To keep the clover watered, Farmer John is inst原创 2013-05-25 00:07:44 · 2217 阅读 · 0 评论 -
基于双队列实现huffman树
今天数算课讲huffman树,是基于堆实现的,突然想起以前实现过基于双队列的huffman树,做个回顾。首先将n个元素从小到大排序,基于比较的排序都是nlogn的复杂度,这里可以考虑用计数排序(即桶排序)或者基数排序尝试优化到n试试。然后我们获得了一个有序队列我们把它放在A队列中,然后再找一个空的B队列。然后从A中或者B中找出两个最小的元素,累加放入B队列的队尾加入。不难发现B队列也是原创 2013-10-16 13:11:40 · 1259 阅读 · 0 评论