摘要: #include <stdio.h> #include <conio.h> void HeapAdjust(int a[],int s,int n)//大顶堆 { int temp=a[s]; for(int j=2*s;j<=n;j*=2) { if(j<n&&a[j]<a[j+1]) j++; if(temp>a[j]) break;//这个错误点困扰了我好长时间。temp写成a[s... 阅读全文
posted @ 2011-06-20 20:48 thinking and coding 阅读(229) 评论(0) 推荐(0) 编辑
摘要: Ø 一个很严肃的问题,如果一个数组是从0开始计数的。那么节点i的左孩子为2i+1,右孩子为2i+2;数据结构课本上的堆中的数组时从1开始计数的。所以做孩子为2i,右孩子为2i+1、 阅读全文
posted @ 2011-06-20 17:17 thinking and coding 阅读(200) 评论(0) 推荐(0) 编辑