What is Binary Search?

Binary Search is an interval searching algorithm used to search for an item in the sorted list. It works by repeatedly dividing the list into two equal parts and then searching for the item that is the part where it can possibly exist.

Unlike linear search, there are a few conditions for applying binary search:

  1. The list must be sorted.
  2. Random access to the list member.

It means that we cannot apply the binary search in unsorted or liked data structures.

C Program for Binary Search

In this article, we will understand the Binary search algorithm and how to write binary search programs in C. We will see both iterative and recursive approaches and how binary search is able to reduce the time complexity of the search operation as compared to linear search.

Similar Reads

What is Binary Search?

Binary Search is an interval searching algorithm used to search for an item in the sorted list. It works by repeatedly dividing the list into two equal parts and then searching for the item that is the part where it can possibly exist....

Algorithm for Binary Search in C

Let  be the element we are searching for and the array is sorted in the ascending order....

Binary Search Program in C (Recursive)

The following C program implements the binary search algorithm using recursion:...

Binary Seach Program in C (Iterative)

...