We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 90bc438 commit 0155fc3Copy full SHA for 0155fc3
十大排序算法_Java/Heap.java
@@ -7,7 +7,7 @@ public class Heap {
7
public int[] heapSort(int[] nums) {
8
n = nums.length;
9
// 堆的构造需要跟子节点比较,所以从最后一个非叶子结点开始向上构造最大堆
10
- for (int i = (n - 1) / 2; i >= 0; i--)
+ for (int i = n / 2 - 1; i >= 0; i--)
11
max_heapify(nums, i);
12
while (n > 0) {
13
// 根节点与最后一个节点交换
0 commit comments