0
0 комментариев

def binary_search(list, item):
low = 0
hight = len(list) — 1

while low <= hight:
mid = (low + hight) / 2
quess = list[mid]
if quess == item:
return mid
elif quess < item:
low = mid + 1
else:
hight = mid — 1
return None

my_list = [1, 2, 3, 5, 8, 10, 12, 19, 28]
print(binary_search(my_list, 5))

Решенный вопрос
Добавить комментарий