You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Binary Search is a searching algorithm used in a sorted array by repeatedly dividing the search interval in half. The idea of binary search is to use the information that the array is sorted and reduce the time complexity to O(Log n).
Binary Search Algorithm: The basic steps to perform Binary Search are:
*Begin with the mid element of the whole array as a search key.
*If the value of the search key is equal to the item then return an index of the search key.
*Or if the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half.
*Otherwise, narrow it to the upper half.
*Repeatedly check from the second point until the value is found or the interval is empty.
*Binary Search Algorithm can be implemented in the following two ways