#binary search algorithm

def binarysearch(arr, left, right, num):
    if right >= left:
        mid = (right + left) // 2
        if arr[mid] == num:
            return mid
        
        elif arr[mid] > num:
            return binarysearch(arr, left, mid - 1, num)
        
        else:
            return binarysearch(arr, mid + 1, right, num)
        
    else:
        return -1
arr = [2, 10, 34, 78, 90]
num = 10
result = binarysearch(arr, 0, len(arr)-1, num)

if result != -1:
    print("element is present in the index ", str(result))
else:
    print("element not in the array")

#binary search algorithm

def binarysearch(arr, left, right, num):
    if right >= left:
        mid = (right + left) // 2
        if arr[mid] == num:
            return mid
        
        elif arr[mid] > num:
            return binarysearch(arr, left, mid - 1, num)
        
        else:
            return binarysearch(arr, mid + 1, right, num)
        
    else:
        return -1
arr = [2, 10, 34, 78, 90]
num = 10
result = binarysearch(arr, 0, len(arr)-1, num)

if result != -1:
    print("element is present in the index ", str(result))
else:
    print("element not in the array")

#binary search algorithm