Question: . , : def binary _ search ( my _ list, x ) : left = 0 right = len ( my _ list )
:
def binarysearchmylist, x:
left
right lenmylist
while left right:
mid leftright
#printmid mylistmid
if mylistmid x:
return True
else:
if mylistmid x: #go to right half
left mid
else: #go to left half
right mid
return False #if we got here the search failed
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
