diff --git a/sorting/heapsort.py b/sorting/heapsort.py index 4317bb9..f474adf 100644 --- a/sorting/heapsort.py +++ b/sorting/heapsort.py @@ -33,7 +33,7 @@ def get_right(i): def repair_heap(vals_list, root, arr_top): """ Sifts the root element of a heap to the correct position, to - correct a max heap. This assumes the children of the root node are max heaps. + correct a max heap. This assumes the children of the root/ node are max heaps. :param vals_list: list of values, which represents a heap structure. :param root: the index of the node we're working from/ using as a root. @@ -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 @@ -118,4 +119,4 @@ if __name__ == "__main__": vals_list = [randint(0, (2**16)) for i in range(list_len)] heap_sorted = heapsort(list(vals_list)) py_sorted = sorted(vals_list) - print("Did the sort work? {}".format(heap_sorted == py_sorted)) \ No newline at end of file + print("Did the sort work? {}".format(heap_sorted == py_sorted))