mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-07 01:50:55 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
94afed0f1d
commit
cd6fca872b
|
@ -1,7 +1,7 @@
|
||||||
def adaptive_merge_sort(sequence: list) -> list:
|
def adaptive_merge_sort(sequence: list) -> list:
|
||||||
"""
|
"""
|
||||||
Sorts a list using the Adaptive Merge Sort algorithm.
|
Sorts a list using the Adaptive Merge Sort algorithm.
|
||||||
|
|
||||||
>>> adaptive_merge_sort([4, 3, 1, 2])
|
>>> adaptive_merge_sort([4, 3, 1, 2])
|
||||||
Initial sequence: [4, 3, 1, 2]
|
Initial sequence: [4, 3, 1, 2]
|
||||||
Sorting: array[0:2] and array[2:4]
|
Sorting: array[0:2] and array[2:4]
|
||||||
|
@ -22,10 +22,11 @@ def adaptive_merge_sort(sequence: list) -> list:
|
||||||
print(f"Sorted sequence: {sequence}")
|
print(f"Sorted sequence: {sequence}")
|
||||||
return sequence
|
return sequence
|
||||||
|
|
||||||
|
|
||||||
def adaptive_merge_sort_helper(array: list, aux: list, low: int, high: int) -> None:
|
def adaptive_merge_sort_helper(array: list, aux: list, low: int, high: int) -> None:
|
||||||
"""
|
"""
|
||||||
Helper function for Adaptive Merge Sort algorithm.
|
Helper function for Adaptive Merge Sort algorithm.
|
||||||
|
|
||||||
>>> adaptive_merge_sort_helper([4, 3, 1, 2], [4, 3, 1, 2], 0, 3)
|
>>> adaptive_merge_sort_helper([4, 3, 1, 2], [4, 3, 1, 2], 0, 3)
|
||||||
Sorting: array[0:2] and array[2:4]
|
Sorting: array[0:2] and array[2:4]
|
||||||
Sorting: array[0:1] and array[1:2]
|
Sorting: array[0:1] and array[1:2]
|
||||||
|
@ -47,6 +48,7 @@ def adaptive_merge_sort_helper(array: list, aux: list, low: int, high: int) -> N
|
||||||
return
|
return
|
||||||
merge(array, aux, low, mid, high)
|
merge(array, aux, low, mid, high)
|
||||||
|
|
||||||
|
|
||||||
def merge(array: list, aux: list, low: int, mid: int, high: int) -> None:
|
def merge(array: list, aux: list, low: int, mid: int, high: int) -> None:
|
||||||
"""
|
"""
|
||||||
Merges two sorted subarrays of the main array.
|
Merges two sorted subarrays of the main array.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user