摘要: #include <iostream>#include <cstdlib>using namespace std;void swap(int array[] , int i , int j){ array[i] = array[i]+array[j]; array[j] = array[i]-array[j]; array[i] = array[i]-array[j];}int Parent(int i){ if(i>1) { return i/2; } else { return 0; }}void MaxHeapify(int array[] , int i 阅读全文
posted @ 2011-02-15 16:21 SunnyDay2015 阅读(342) 评论(0) 推荐(0) 编辑
摘要: Heap-Delete(A; i)1 if i > heap-size[A]2 then error “heap underflow”3 A[i] à A[heap-size[A]]4 heap-size à heap-size-15 if A[i] > A[Parent(i)]6 then Heap-Increase-Key(A; i;A[i]) 阅读全文
posted @ 2011-02-15 16:20 SunnyDay2015 阅读(371) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>using namespace std;void swap(int array[] , int i , int j){ array[i] = array[i]+array[j]; array[j] = array[i]-array[j]; array[i] = array[i]-array[j];}void MaxHeapify(int array[] , int i , int hSize){ int l = 2*i; int r = 2*i+1; int largest; while(l <= hSize) { if(array[l] 阅读全文
posted @ 2011-02-15 11:04 SunnyDay2015 阅读(441) 评论(0) 推荐(0) 编辑