In the first iteration the center most element is compared with search data. Binary search is an efficient algorithm that searches a sorted list for a desired, or target, element. In other words, binary search requires the ability to look immediately at any item in the data set, given an index number for it. Then it is halved. Your data must be sorted according to the given comparator for the binary search to work as intended. In this tutorial, you will understand the working of binary search with working code in C, C++, Java, and Python. A binary search works by halving the sorted list. It's time complexity of O(log n) makes it very fast as compared to other sorting algorithms. Binary search is an extremely simple idea that’s useful for much more than finding an element in a sorted array. This method is done by starting with the whole array. (If it's not, the behavior is undefined.) I also tested to do a manual BINARY SEARCH and start looping from that position until i found a different combination for my key fields, this is a solution i usually used when i didn’t understand how ABAP works, i surprisingly found that it performs slightly better, may be useful if you need to squeeze until the last bit of performance. Binary Search is applied on the sorted array or list of large size. Binary Search is a method to find the required element in a sorted array by repeatedly halving the array and searching in the half. The only limitation is that the array or list of elements must be sorted for the binary search algorithm to work on it. Binary search requires a data structure that supports random access. Binary Search is a searching algorithm for finding an element's position in a sorted array. Binary Search Algorithm. The way binary search works is you compare the item you want to find with the item in the middle of the array, then whichever “side” of the midpoint of the array your element falls on, you compare it to the midpoint of that half until you find the item you want.