You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please write a binary search function which searches an item in a sorted list. The function should return the index of element to be searched in the list.
def binary_search_Ascending(array, target):
lower = 0
upper = len(array)
print('Array Length:',upper)
while lower < upper:
x = (lower + upper) // 2
print('Middle Value:',x)
value = array[x]
if target == value:
return x
elif target > value:
lower = x
elif target < value:
upper = x
Array = [1,5,8,10,12,13,55,66,73,78,82,85,88,99]
print('The Value Found at Index:',binary_search_Ascending(Array, 82))