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:
- The list must be sorted.
- 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.