text_plain_output_1.png
def linearSearch(array, n, x):
    for i in range(0, n):
        if array[i] == x:
            return i
    return -1
array = [10, 20, 30, 40, 50, 60, 70]
x = 50
n = len(array)
result = linearSearch(array, n, x)

def binary_search_recursive(array, element, start, end):
    if start > end:
        return -1
    mid = (start + end) // 2
    if element == array[mid]:
        return mid
    if element < array[mid]:
        return binary_search_recursive(array, element, start, mid - 1)
    else:
        return binary_search_recursive(array, element, mid + 1, end)

element = 50
array = [10, 20, 30, 40, 50, 60, 70]
print('Searching for {}'.format(element))
print('Index of {}: {}'.format(element, binary_search_recursive(array, element, 0, len(array))))