We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9e031e9 commit d313874Copy full SHA for d313874
sorts/heap_sort.py
@@ -42,13 +42,13 @@ def heap_sort(unsorted):
42
>>> heap_sort([-2, -5, -45])
43
[-45, -5, -2]
44
"""
45
- n=len(unsorted)
46
- for i in range (n/2 - 1 , -1, -1):
47
- heapify(unsorted,i,n)
48
- for i in range(n - 1, -1, -1):
49
- unsorted[0], unsorted[i] = unsorted[i], unsorted[0]
50
- heapify(unsorted,0,i)
51
- return unsorted
+ n=len(unsorted)
+ for i in range (n/2 - 1 , -1, -1):
+ heapify(unsorted,i,n)
+ for i in range(n - 1, -1, -1):
+ unsorted[0], unsorted[i] = unsorted[i], unsorted[0]
+ heapify(unsorted,0,i)
+ return unsorted
52
53
54
if __name__ == '__main__':
0 commit comments