随笔分类 - 堆排序
摘要:有n(n>=1&&n1&&node[i]>n) { node[0]=0; for(i=1;i>node[i]; inheap(node[i]); } __int64 ans=0; for(i=1;i...
阅读全文
摘要:http://poj.org/problem?id=2051DescriptionA data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor data, Inter...
阅读全文
摘要:DescriptionGiven m sequences, each contains n non-negative integer. Now we may select one number from each sequence to form a sequence with m integers...
阅读全文
摘要:STL的堆操作STL里面的堆操作一般用到的只有4个:make_heap();、pop_heap();、push_heap();、sort_heap();他们的头文件函数是#include 首先是make_heap();他的函数原型是:void make_heap(first_pointer,end_...
阅读全文
摘要:最大堆/最小堆 堆的定义是:n个元素的序列{k1,k2,…,kn},当且仅当满足如下关系时被成为堆 (1)Ki= k2i且 ki>= k2i-1 (i = 1,2,…[n/2])当满足(1)时,为最小堆,当满足(2)时,为最大堆。 若将此序列对应的一维数组堪称是一个完全二叉树...
阅读全文
摘要:堆排序 堆排序是利用堆的性质进行的一种选择排序。下面先讨论一下堆。1.堆堆实际上是一棵完全二叉树,其任何一非叶节点满足性质: Key[i]=Key[2i+1]&&key>=key[2i+2] 即任何一非叶节点的关键字不大于或者不小于其左右孩子节点的关键字。 堆分为大顶堆和小顶堆,满足Key[i]>=...
阅读全文

浙公网安备 33010602011771号