割り当てにヒープソートを実装しています。私たちは彼女がクラスで彼女の擬似コードを使って行ったのと同じ方法でそれをしなければなりません、さもなければ私たちは信用を得ません。
ランタイムエラーが発生しました:変数'heapArray'の周りのスタックが破損しました。デバッガーを試してみましたが、エラーの原因を特定できませんでした。HeapSort()関数のForループと関係があると確信しています。誰か助けてもらえますか?
void HeapSort(int heapArray[])
{
int heap_size = SIZE;
int n = SIZE;
int temp;
Build_Max_Heap(heapArray);//function not implemented, only declared for compile
for(int i = n; i >=2; i--) //***I think error coming from something in here
{
temp = heapArray[1];
heapArray[1] = heapArray[i];
heapArray[i] = temp;
heap_size = heap_size-1;
Max_Heapify(heapArray,1);//function not implemented, only declared for compile
}
return;
}
int main()
{
int heapArray[SIZE] = { 5 ,99, 32, 4, 1, 12, 15 , 8, 13, 55 };
HeapSort(heapArray);
cout << endl;
return 0;
}