summaryrefslogtreecommitdiff
path: root/progs/a339.py
diff options
context:
space:
mode:
authorL0P0P <grassoemanuele@live.com>2024-06-27 12:02:35 +0200
committerL0P0P <grassoemanuele@live.com>2024-06-27 12:02:35 +0200
commit3c4229fc9e0ec6da9a7f60b57b9e93c49d1b6b6c (patch)
treeaca198eca62a0260a50ea59003c44a942e98f521 /progs/a339.py
parentfb89b8c0885ee4e289cfb577bbabf0ee66b05024 (diff)
Fixed a lot of problems from all the progs we need to parse
Diffstat (limited to 'progs/a339.py')
-rw-r--r--progs/a339.py51
1 files changed, 27 insertions, 24 deletions
diff --git a/progs/a339.py b/progs/a339.py
index 9a57403..95724d2 100644
--- a/progs/a339.py
+++ b/progs/a339.py
@@ -1,25 +1,28 @@
-def heap_sort(arr):
- heapify(arr)
- end = len(arr) - 1
- while end > 0:
- arr[end], arr[0] = arr[0], arr[end]
- shift_down(arr, 0, end - 1)
- end -= 1
- return arr
+# FIXME: chiamata a funzione definita dopo
+#
+# def heap_sort(arr):
+# heapify(arr)
+# end = len(arr) - 1
+# while end > 0:
+# arr[end], arr[0] = arr[0], arr[end]
+# shift_down(arr, 0, end - 1)
+# 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:
- child = root * 2 + 1
- if child + 1 <= end and arr[child] < arr[child + 1]:
- child += 1
- if child <= end and arr[root] < arr[child]:
- arr[root], arr[child] = arr[child], arr[root]
- root = child
- else:
- return
+# 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:
+# child = root * 2 + 1
+# if child + 1 <= end and arr[child] < arr[child + 1]:
+# child += 1
+# if child <= end and arr[root] < arr[child]:
+# arr[root], arr[child] = arr[child], arr[root]
+# root = child
+# else:
+# return