Linear Search is a procedure to find a particular element in a array or list. We find a target element within a array in a squential manner ,until the element is found. Once the element is found, the execution stops and returns the position of the element in the array(or list) if the search element is found or else send a message stating the element is not found.
This algorithm is less efficient when compared to other searching algorithms (like Binary search) as all the elements have to be parsed in order to find the search element.
The time complexity for linear search is O(N). Best case of O(1) comes in situation when the element to search is the first element of the array.
Name | Best | Average | Worst | Memory |
---|---|---|---|---|
Linear Search | 1 | n | n | 1 |