Open In App

What is Binary Search Algorithm?

Last Updated : 02 Mar, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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?


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads