public class BinarySearch { public static void main(String[] args) { int[] arr = {2, 5, 8, 12, 16, 23, 38, 45, 56, 72, 91}; int target = 23; int result = binarySearch(arr, target); if (result != -1) { System.out.println("Element " + target + " found at index " + result); } else { System.out.println("Element " + target + " not found in the array"); } } static int binarySearch(int[] arr, int target) { int low = 0, high = arr.length - 1; while (low <= high) { int mid = low + (high - low) / 2; if (arr[mid] == target) return mid; else if (arr[mid] < target) low = mid + 1; else high = mid - 1; } return -1; } }