Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b7ecd16

Browse files
committedOct 11, 2024·
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d12949d commit b7ecd16

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed
 

‎sorts/adaptive_merge_sort.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from typing import List
77

8+
89
def adaptive_merge_sort(sequence: list) -> list:
910
"""
1011
>>> adaptive_merge_sort([12, 11, 13, 5, 6, 7])
@@ -23,6 +24,7 @@ def adaptive_merge_sort(sequence: list) -> list:
2324
adaptive_merge_sort_recursive(sequence, aux, 0, len(sequence) - 1)
2425
return sequence
2526

27+
2628
def adaptive_merge_sort_recursive(arr: list, aux: list, low: int, high: int) -> None:
2729
if high <= low:
2830
return
@@ -32,11 +34,12 @@ def adaptive_merge_sort_recursive(arr: list, aux: list, low: int, high: int) ->
3234
adaptive_merge_sort_recursive(aux, arr, mid + 1, high)
3335

3436
if arr[mid] <= arr[mid + 1]:
35-
arr[low:high + 1] = aux[low:high + 1]
37+
arr[low : high + 1] = aux[low : high + 1]
3638
return
3739

3840
merge(arr, aux, low, mid, high)
3941

42+
4043
def merge(arr: list, aux: list, low: int, mid: int, high: int) -> None:
4144
i, j = low, mid + 1
4245

@@ -58,4 +61,9 @@ def merge(arr: list, aux: list, low: int, mid: int, high: int) -> None:
5861
if __name__ == "__main__":
5962
assert adaptive_merge_sort([12, 11, 13, 5, 6, 7]) == [5, 6, 7, 11, 12, 13]
6063
assert adaptive_merge_sort([4, 3, 2, 1]) == [1, 2, 3, 4]
61-
assert adaptive_merge_sort(["apple", "zebra", "mango", "banana"]) == ['apple', 'banana', 'mango', 'zebra']
64+
assert adaptive_merge_sort(["apple", "zebra", "mango", "banana"]) == [
65+
"apple",
66+
"banana",
67+
"mango",
68+
"zebra",
69+
]

0 commit comments

Comments
 (0)
Please sign in to comment.