Sunday, October 6, 2024
Google search engine
HomeData Modelling & AIWhat is Binary Search Algorithm?

What is Binary Search Algorithm?

Binary Search is a searching algorithm used in a sorted array by repeatedly dividing the search interval in half and the correct interval to find is decided based on the searched value and the mid value of the interval.

Example of binary search

Example of binary search

Properties of Binary Search:

  • Binary search is performed on the sorted data structure for example sorted array. 
  • Searching is done by dividing the array into two halves. 
  • It utilizes the divide-and-conquer approach to find an element.

Pre-requisites to apply Binary Search Algorithm:

For applying binary search in any data structure, the data structure must satisfy the following two conditions:

  • The data structure is sorted.
  • Any random element of the data structure can be directly accessed i.e., can be accessed in constant time.

Applications of Binary Search:

  • The binary search operation is applied to any sorted array for finding any element. 
  • Binary search is more efficient and faster than linear search. 
  • In real life, binary search can be applied in the dictionary.
  • Binary search is also used to debug a linear piece of code.
  • Binary search is also used to find if a number is a square of another or not.

What else can you read?

Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!

RELATED ARTICLES

Most Popular

Recent Comments