def binary_search(a,low,high,key):
    if(low <= high):
        mid = (low + high)//2
        if(a[mid] == key):
            return mid
        elif(a[mid] > key):
            return binary_search(a,low,mid-1,key)
        else:
            return binary_search(a,mid+1,high,key)
    else:
        return -1

a = [int(i) for i in input().split()]
key = int(input())
res = binary_search(a,0,len(a)-1,key)
if(res == -1):
    print("Element not found")
else:
    print("Element found at : " + str(res))
    

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: