Seth.

Linear Search

Linear Search - Technical Overview

1. Algorithm Description: Linear Search is a simple search algorithm that checks each element of the array until the target is found or all elements are checked.

2. Steps of Linear Search:

  • Start from the first element of the array.
  • Compare each element with the target.
  • If the target is found, return its index.
  • If the target is not found after checking all elements, return -1.

3. Time Complexity: O(n), where n is the number of elements in the array.

4. Space Complexity: O(1), as it operates in-place.

5. Stability: Linear Search is a stable search algorithm since it preserves the relative order of equal elements.

6. Usage: Linear Search is generally used in unsorted arrays where binary search cannot be applied.