Linear search using recursion
def linear_search(arr, key, size):
if size == 0:
return -1
elif arr[size - 1] == key:
return size - 1
else:
return linear_search(arr, key, size - 1)
arr = [10, 20, 30, 40, 50]
key = 20
size = len(arr)
ans = linear_search(arr, key, size)
if ans != -1:
print('The element', key, 'is found at', ans, 'index of the given array')
else:
print('The element', key, 'is not found')