Search is a find an element from a Given data structure such as an array or list. There are two types of search Algorithms.

  • Linear Search
  • Binary Search
  • Hashing Search

What is a Linear Search Algorithm

Linear Search is a sequential Search algorithm in which It starts searching for a given element at one end, traverses the given list until the given element is found

Linear Search is used for a small set of data and a list of elements is not sorted

Binary Search Algorithm

The search Algorithm finds the search element in the sorted array,

  • First Compare the Search element in the middle of the value of an array.
  • If the element is not equal in half range, Ignore this range and
  • Compare the number in the other half orange
  • Repeat the process until the element is found.

It runs in logarithmic time (O(log n)) in the worst and average case Best case is O(1)