Skip to content

Commit 0155fc3

Browse files
authored
Update Heap.java
1 parent 90bc438 commit 0155fc3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

十大排序算法_Java/Heap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class Heap {
77
public int[] heapSort(int[] nums) {
88
n = nums.length;
99
// 堆的构造需要跟子节点比较,所以从最后一个非叶子结点开始向上构造最大堆
10-
for (int i = (n - 1) / 2; i >= 0; i--)
10+
for (int i = n / 2 - 1; i >= 0; i--)
1111
max_heapify(nums, i);
1212
while (n > 0) {
1313
// 根节点与最后一个节点交换

0 commit comments

Comments
 (0)