Skip to content

Commit 36b2283

Browse files
committed
堆排序
1 parent db4de75 commit 36b2283

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

各种排序/堆排序/HeapSort.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ void Heap_Sort(int *arr,int len)
4141
{
4242
int i;
4343
//把数组建成为最大堆
44-
//第一个非叶子节点的位置序号为(len-1)/2
45-
for(i=(len-1)/2;i>=0;i--)
44+
//第一个非叶子节点的位置序号为len/2-1
45+
for(i=len/2-1
46+
;i>=0;i--)
4647
HeapAdjustDown(arr,i,len-1);
4748
//进行堆排序
4849
for(i=len-1;i>0;i--)

0 commit comments

Comments
 (0)