摘要:
今天偶然看到一个找出N个数中最大的前500个数,一个不错的解法是使用堆来进行选择,每一次读取一个数判断是否需要放到堆中,这样比较下来就可以找到最大或最小的前500个数了,自己晚上就参考别人的代码写了一个最小堆的结构,后期继续补充。View Code #include <stdio.h>#include <stdlib.h>typedef int ElemType;struct heap{ ElemType *num; int heapsize; int maxSize;};struct heap HP;int init_heap(int size){ if(size . 阅读全文
posted @ 2012-02-16 00:03
北海石松
阅读(283)
评论(0)
推荐(0)
浙公网安备 33010602011771号