What is Linear Search?

Linear Search, also known as Sequential Search, is the most common searching algorithm. In this method, each element in the list is checked sequentially until the target element is found or the end of the list is reached.

Characteristics of Linear Search:

  • Linear Search starts from the first element and moves sequentially to the next element.
  • Inefficient for large datasets because of its linear time complexity.
  • Easy to implement and understand.
  • Linear Search has time complexity of O(N) where N is the number of elements in the list.

Example:

Consider an array arr[] = {10 ,20, 30, 40, 50} and the element to be searched, that is the target is 30.

  • Start from the first element (index = 0), arr[0] = 10 which is not equal to the target element 30.
  • Move to the second element (index = 1), arr[1] = 20 which is also not equal to the target element 30.
  • Move to the third element (index = 2), arr[2] = 30, which is equal to the target element 30. So, return 2 as the index where target element is present.

Difference Between Linear Search and Jump Search

Linear Search and Jump Search are two different techniques used to find an element in a list. Each algorithm has its own set of characteristics, advantages, and limitations, making them suitable for different scenarios. This article explores the key differences between Linear Search and Jump Search.

Similar Reads

What is Linear Search?

Linear Search, also known as Sequential Search, is the most common searching algorithm. In this method, each element in the list is checked sequentially until the target element is found or the end of the list is reached....

What is Jump Search?

Jump Search is an algorithm for searching in sorted arrays. It reduces the time complexity compared to Linear Search by jumping ahead by fixed steps and then performing a linear search within the identified block. The basic idea is to check fewer elements by jumping ahead by fixed steps or skipping some elements in place of searching all elements....

Linear Search vs. Jump Search:

...