blob: 370a4d9d0d92a0a648476705c9ccb0f02eec3aa4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
def binary_search(item_list,item):
first = 0
last = len(item_list)-1
found = False
while( first<=last and not found):
mid = (first + last)//2
if item_list[mid] == item :
found = True
else:
if item < item_list[mid]:
last = mid - 1
else:
first = mid + 1
return found
|