Question: . , : def binary _ search ( my _ list, x ) : left = 0 right = len ( my _ list )

.
,:
def binary_search(my_list, x):
left =0
right = len(my_list)-1
while left <= right:
mid =(left+right)//2
#print(mid, my_list[mid])
if my_list[mid]== x:
return True
else:
if my_list[mid]< x: #go to right half
left = mid+1
else: #go to left half
right = mid-1
return False #if we got here the search failed
[100,110,120,130,140,150,160,170],135.?
130,"150"140
130,"160"150
130,"150
130,"140

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!