Linear Search is a simple searching algorithm that sequentially checks each element in an array until the target element is found or the search completes.
-
Start from index
i = 0 -
Repeat until
i < n(size of the array):
a. Ifarray[i] == search_key:
- Return i (found at index i)b. Else, move to the next element
-
If not found,
return -1(element does not exist)
