Linear Search: Searching Algorithm

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.

Image for post
Image Source : Tutorial Point

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.

Logic Building

Iterate each element of the given array and compare it against your target element.

Python Code

def linear_search(arr, target):
	for t in arr:
			print("I found target element in given array")

arr = [1,9,5,3,22,88,92,12,34]
target = 12


Leave a Comment