Linear Search

A linear search, also known as a sequential search, is a method of finding an element within a list. It checks each element of the list sequentially until a match is found or the whole list has been searched.

Algorithm

  1. Start from the leftmost element of arr[] and one by one compare with each element of arr[].
  2. If x matches with an element, return the index.
  3. If x doesn't match with any of the elements, return -1.

Program using C