Algorithm


Linear Search Algorithm:

  1. Start with an unsorted or sorted array and a target element to search for.
  2. Traverse the array from the first element to the last element:
    1. Compare the current element with the target element.
    2. If they match, return the index of the current element.
  3. If the target element is not found after traversing the entire array, return "Not Found."

Example:

Linear Search Example

Fig. 1: Step-by-Step Process of Linear Search

Note: Linear Search is simple but may not be efficient for large arrays.