Linear Search

Linear Search:

Linear search will exhaustively search a given n element in an Array.
The iterator will search left to right until it finds the element given. 

Example:

n = e5;

Search(n) in Array;

Array = [‘e1’,’e2’,’e3’,’e4’,’e5’,’e6’,’e7’,’e8’,’e9’];

Algorithm:

  • Repeat, start at the first element:
  • Check on each element left to right, and find the one that matches n? Then Stop-iteration.  
  • Else, continue until the last element of the Array.