Linear search algorithm

The idea

Linear search algorithm
The Linear search algorithm aims to find the target value inside a collection. It has time complexity of O(n) (linear time complexity).

These are the steps for the algorithm:

  1. Start at the first element and check if it is the target. If it is, the algorithm is done.
  2. Otherwise, it checks the second element.
  3. It keeps checking the next element until it finds the target or reaches the end of the collection, which means the target wasn't in it.

Relations

Sources