WHAT IS THE CORRECT OPTION OF BINARY SEARCH ALGORITHAM
5 po
O MID VALUE FORMULA IS MID-LOW+HIGH/2
O
IF LIMID]<MID THEN THE SEARCH ELEMENT WILL BE IN THE LEFT HALF OF LIST
O IF LIMID]>MID THEN THE SEARCH ELEMENT WILL BE IN THE RIGHT HALF OF LIST
O ALL
Answers
Answer:
# resursive function for binary search
def binary_search(l,ele,low,high):
if low<=high:
mid=(low+high)//2
if l[mid]==ele:
return mid
elif ele<l[mid]:
high = mid-1
return binary_search(l,ele,low,mid)
else:
return binary_search(l,ele,low,high)
else:
return None
# main
my_list=eval(input("enter the list"))
element=int(input("enter the list element to be searched for"))
l=int(input("enter the lowest index of the list"))
h=int(input("enter the highest index of the list"))
pos=binary_search(my_list,element,l,h)
if pos!=None:
print("element is found in the position",pos)
else:
print("the element that you have searched for is not found in the list you have given")
#hope it helps you!!!
please mark brainliest