Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6652ed4

Browse files
committed
update code
1 parent 5cc29d8 commit 6652ed4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

‎src/main/java/grey/algorithm/code11_heap/Code_0002_MaxHeap.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ private void heapify() {
6565
= left + 1 < heapSize // right child exist
6666
&& heap[left + 1] > heap[left] // compare left child and right child
6767
? left + 1 : left;
68-
largest = heap[largest] > heap[index] ? largest : index;
69-
if (largest == index) {
68+
if (heap[largest] <= heap[index]) {
7069
break;
7170
}
7271
swap(heap, largest, index);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /