(int arr[], int n, int x)
| 5 | { |
| 6 | |
| 7 | static int exponentialSearch(int arr[], |
| 8 | int n, int x) |
| 9 | { |
| 10 | if (arr[0] == x) |
| 11 | return 0; |
| 12 | |
| 13 | int i = 1; |
| 14 | while (i < n && arr[i] <= x) |
| 15 | i = i*2; |
| 16 | |
| 17 | return Arrays.binarySearch(arr, i/2, |
| 18 | Math.min(i, n-1), x); |
| 19 | } |
| 20 | |
| 21 | public static void main(String args[]) |
| 22 | { |
no test coverage detected