Back

Real World Examples

The linear search is the simplest of the searching algorithms to implement. This makes it well suited to beginner programmers.

It is most effective on small arrays, as only a few elements will be compared even in the worst case. Although there are more efficient searching algorithms, such as the binary search, these may require the list to be sorted. Linear searches can be performed on unsorted arrays. This is useful for small data sets, as sorting and searching may take longer than a simple linear search.

Linear searches are also useful when performing a single search in an unordered search. For a single search, sorting the data is unnecessary. When looking for a specific file on your computer, for example searching for a Word document by its name, the computer may perform a linear search on your file directory.