Binary Search on Arrays
Binary search is an efficient algorithm for finding a target value within a sorted array. It works by repeatedly dividing the search interval in half. If the target value is less than the middle element, the search continues on the left half; otherwise, it continues on the right half. This process is repeated until the target value is found or the interval is empty. Its time complexity is , making it much faster than linear search for large arrays.
Raouf's note : Focus well on choosing the middle index, because it may lead to an infinite loop if not done properly. Details are well discussed in the resources below.
Resources
It is higly recommended to go over all the resources
- GeeksforGeeks - Binary Search
- Binary Search in 4 minutes - YouTube (en)
- Basics of Binary Search — Tips to solve binary search problems
- MARK AI Code - Binary Search in C++ : A comprehensive guide to STL implementation
- #3- شرح مفهوم الـ Binary Search بكل تفاصيله (ar)
- AOI December Camp 2025 Lecture on Binary Search (ar)

