Skip to content

Commit 3a6a8b3

Browse files
committed
Merge pull request nryoung#38 from ConanChou/master
Fixed the binary tree left and right nodes calculation
2 parents 9e85c1f + b2f22d1 commit 3a6a8b3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

algorithms/sorting/heap_sort.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919

2020

2121
def max_heapify(seq, i, n):
22-
l = i + 1
23-
r = i + 2
22+
l = 2 * i + 1
23+
r = 2 * i + 2
2424

2525
if l <= n and seq[l] > seq[i]:
2626
largest = l

0 commit comments

Comments
 (0)