Linear Search is also sometimes referred to as a sequential search, as it refers to a method of searching performed in sequence.
The linear search algorithm is one of the most simple computer science algorithms and is quick and easy to implement, requiring very little coding to do so. Because of this, the linear search algorithm is often the best choice for very small lists or data sets.
The way this algorithm works is to take the first item in the list. It will compare this item with what it is searching for. If the two match, then great that’s the search over. If not, it moves on in order to the next item and starts the check again. It repeats this process, going through the list sequentially, until either it finds what it is looking for, or it gets to the end. If it makes it to the end then it will return a negative result telling the user that what they were looking for was not found.
Unfortunately, due to the sequential nature of this type of search, the potential worst-case time for completion increases with the size of the data to search through. This means that for large data sets it could be a very poor choice of algorithm.
In situations like this, it is much better to implement a more complicated type of search algorithm that would take more coding to implement but would achieve faster search times. One such algorithm is known as the binary search algorithm.