Skip to content

Commit 7f00d59

Browse files
github-actionsgithub-actions
authored andcommitted
fixup! Format Python code with psf/black push
1 parent 33b5dc5 commit 7f00d59

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

sorts/recursive_insertion_sort.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from typing import List
66

7+
78
def rec_insertion_sort(collection: List, n: int):
89
"""
910
Given a collection of numbers and its length, sorts the collections
@@ -27,13 +28,13 @@ def rec_insertion_sort(collection: List, n: int):
2728
>>> print(col)
2829
[1]
2930
"""
30-
#Checks if the entire collection has been sorted
31+
# Checks if the entire collection has been sorted
3132
if len(collection) <= 1 or n <= 1:
3233
return
3334

35+
insert_next(collection, n - 1)
36+
rec_insertion_sort(collection, n - 1)
3437

35-
insert_next(collection, n-1)
36-
rec_insertion_sort(collection, n-1)
3738

3839
def insert_next(collection: List, index: int):
3940
"""
@@ -54,17 +55,19 @@ def insert_next(collection: List, index: int):
5455
>>> print(col)
5556
[]
5657
"""
57-
#Checks order between adjacent elements
58+
# Checks order between adjacent elements
5859
if index >= len(collection) or collection[index - 1] <= collection[index]:
5960
return
6061

61-
#Swaps adjacent elements since they are not in ascending order
62+
# Swaps adjacent elements since they are not in ascending order
6263
collection[index - 1], collection[index] = (
63-
collection[index], collection[index - 1]
64+
collection[index],
65+
collection[index - 1],
6466
)
6567

6668
insert_next(collection, index + 1)
6769

70+
6871
if __name__ == "__main__":
6972
numbers = input("Enter integers seperated by spaces: ")
7073
numbers = [int(num) for num in numbers.split()]

0 commit comments

Comments
 (0)