Browse Source

Better formatting

Adjusted the spacing of the functions to be more PEP friendly.
pull/24/head
James Sherratt 4 years ago
parent
commit
fc6375a039
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      sorting/heapsort.py

+ 3
- 1
sorting/heapsort.py View File

@ -65,6 +65,7 @@ def repair_heap(vals_list, root, arr_top):
root = swap
left = get_left(root)
right = get_right(root)
return vals_list
@ -79,6 +80,7 @@ def max_heap(vals_list):
len_list = len(vals_list)
for root in range(len_list//2, -1, -1):
repair_heap(vals_list, root, len_list)
return vals_list
@ -97,8 +99,8 @@ def max_heap_to_sorted(vals_list):
# Another way of doing this is to pass a slice of the vals_list up to the value top, but python passes
# slices by copy so there's a massive performance hit.
repair_heap(vals_list, 0, top)
return vals_list
return vals_list
def heapsort(vals_list):

Loading…
Cancel
Save