Binary Search in Java
Binary Search Algorithm Binary Search works on sorted arrays and uses divide-and-conquer: Find the middle element. If it matches the target, return the index. If target < middle, search the left half. If target > middle, search the right half. Repeat until found or range is empty. Time complexity: O(log n)Space complexity: O(1) for…