MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / binary_search

Function binary_search

sorts/tim_sort.py:4–16  ·  view source on GitHub ↗
(lst: list[Any], item: Any, start: int, end: int)

Source from the content-addressed store, hash-verified

2
3
4def binary_search(lst: list[Any], item: Any, start: int, end: int) -> int:
5 if start == end:
6 return start if lst[start] > item else start + 1
7 if start > end:
8 return start
9
10 mid = (start + end) // 2
11 if lst[mid] < item:
12 return binary_search(lst, item, mid + 1, end)
13 elif lst[mid] > item:
14 return binary_search(lst, item, start, mid - 1)
15 else:
16 return mid
17
18
19def insertion_sort(lst: list[Any]) -> list[Any]:

Callers 1

insertion_sortFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected