summaryrefslogtreecommitdiff
path: root/progs/a339.py
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2024-06-27 22:41:06 +0200
committerSanto Cariotti <santo@dcariotti.me>2024-06-27 22:41:06 +0200
commit49357616859faaf9e53468ce71d6cd99bda4fb4a (patch)
treed861f4962fce25638a348f81609562b85ec18174 /progs/a339.py
parentd653d3598d71fea30d45d118e3d046a3aed53ac1 (diff)
Restore progs folder
Diffstat (limited to 'progs/a339.py')
-rw-r--r--progs/a339.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/progs/a339.py b/progs/a339.py
index 53fcb7e..9a57403 100644
--- a/progs/a339.py
+++ b/progs/a339.py
@@ -1,5 +1,5 @@
def heap_sort(arr):
- heapify(arr)
+ heapify(arr)
end = len(arr) - 1
while end > 0:
arr[end], arr[0] = arr[0], arr[end]
@@ -7,14 +7,11 @@ def heap_sort(arr):
end -= 1
return arr
-
def heapify(arr):
start = len(arr) // 2
while start >= 0:
shift_down(arr, start, len(arr) - 1)
start -= 1
-
-
def shift_down(arr, start, end):
root = start
while root * 2 + 1 <= end: