Searching is a important task in computer programming and there are number of algorithms and techniques to search any element in array. I am going to discuss linear search in this blog.
In linear search we compare our target element with every element of array. The program will stop when element is equal to our target element. Array can be sorted and unsorted.
Iterate each element of the given array and compare it against your target element.
def linear_search(arr, target): for t in arr: if(target==t): print("I found target element in given array") else: continue arr = [1,9,5,3,22,88,92,12,34] target = 12 linear_search(arr,target)