
算法
文章平均质量分 73
Bupt_Tornado
这个作者很懒,什么都没留下…
展开
-
堆排序
排序算法之堆排序1. 堆堆一般指二叉堆,是一颗完全二叉树,可以很方便的用数组存储数据,其父节点和子节点满足如下关系:parent(i)= i/2; leftchild(i) = 2*I; rightchild = 2*i+1。再用数组存储时注意,数组小标从1开始。最大堆:父节点的值大于子节点的值。最小堆:父节点的值小于子节点的值。几个时间复杂度:保持堆性质的操作:原创 2013-04-23 15:29:44 · 426 阅读 · 0 评论 -
最小生成树
图算法之最小生成树1. 对于一个无向连通图G=(V,E),若存在一个无回路的子集TE,它连接了所有的顶点,切其权值之和:2. Kruskal算法伪代码如下:MST_KRUSKAL(G,w) A = {} for vertex in V do make-set(v) sort the edges based on weight for edge(u原创 2013-04-24 11:26:38 · 457 阅读 · 0 评论 -
N个数中第k大的元素
// 3 implement the function : int part(int *a,int low,int high), and implement the function to find the k-st num in a array a[low] as the pivot element int part(int *a,int low,int high){ int temp原创 2013-06-30 20:16:50 · 642 阅读 · 0 评论