摘要:
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]) 阅读全文
摘要:
#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] 阅读全文