Question: ` ` ` import numpy as np def binary _ search ( sequence , item _ to _ search ) : ' ' ' The

```
import numpy as np
def binary_search(sequence, item_to_search):
'''
The code for binary search has been provided. Please modify the code so that
it will return the number of steps it took to find the minimum index of the
number using binary search, given that the number is in the sequence.
In other words, the program should not stop the first time it finds the
number in the sequence, but continue binary search until it finds the minimum
index the number appears at.
>>>print(binary_search([1,1,1,2,3,4],1))
2
>>>print(binary_search([1,1,1,2,2,2,3,3,4],3))
2
'.'
low =0
high = len(sequence)-1
while low = high:
middle =(low + high)//2
if sequence[middle] item_to_search:
low = middle +1
elif sequence[middle]> item_to_search:
high = middle -1
else:
return middle
return None
```
` ` ` import numpy as np def binary _ search (

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!