Skip to content

Commit 0b5c1b2

Browse files
Added missing docstrings to helper functions
1 parent 6c04620 commit 0b5c1b2

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

sorts/tim_sort.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33

44
def binary_search(lst: list[Any], item: Any, start: int, end: int) -> int:
5+
"""
6+
Find the index where an item should be inserted in a sorted list
7+
"""
8+
59
if start == end:
610
return start if lst[start] > item else start + 1
711
if start > end:
@@ -17,6 +21,10 @@ def binary_search(lst: list[Any], item: Any, start: int, end: int) -> int:
1721

1822

1923
def insertion_sort(lst: list[Any]) -> list[Any]:
24+
25+
"""
26+
Sort a list using insertion sort and binary search
27+
"""
2028
length = len(lst)
2129

2230
for index in range(1, length):
@@ -28,6 +36,10 @@ def insertion_sort(lst: list[Any]) -> list[Any]:
2836

2937

3038
def merge(left: list[Any], right: list[Any]) -> list[Any]:
39+
40+
"""
41+
Merge two sorted lists into one sorted list
42+
"""
3143
if not left:
3244
return right
3345

0 commit comments

Comments
 (0)