# Linear Search Algorithm

--

A sequential search technique known as “linear search” starts at the back or the front and works its way to the other end until the search key is discovered.

# Iterative Approach

**Steps to implement to algorithm iteratively.**

1. Start from one end of the list and compare the desired element with each element of arr[].

2. If it matches the desired element then it returns the index value.

3. If it doesn’t match with any elements in the list then it returns -1;

**The complexity of the Iterative algorithm***Time Complexity O(n) *

Time will be dependent on the length of the array.*Space Complexity O(1)*

There is no additional space required when the length of the list increases or decreases

# Recursive Approach

Steps to implement the algorithm recursively.

1. If the size of the array is equal to 1 then return -1, representing the element not found in the list

2. Otherwise check if the element is present at the current index position.

If the element is found at the current location then return the index position-1

The complexity of the recursive algorithm.*Time Complexity O(n) *

Time will be dependent on the length of the array.*Space Complexity O(n)*

There is no additional space requirement for using recursive stack space.