is a popular algorithm used to efficiently search for a in a . It follows the strategy, where the array is repeatedly divided in half until the target element is found. The occurs by continuously narrowing down the search space based on a and of the mid-point element with the target element.
The main advantage of binary search lies in its significant reduction of the search space with each iteration. This allows for a fast search process, resulting in a logarithmic of O(log n), where n represents the size of the array. The of binary search is relatively low with O(1), as it only requires a small amount of additional space to store the mid-point index and the comparison result.
Keywords
target element | index | binary search | divide and conquer | mid-point | comparison | space complexity | iteration | time complexity | sorted array |