Driver program
public static void main ( String [ ] args ) { int arr [ ] = { 6 , 7 , 8 , 11 , 9 , 5 , 2 , 1 } ; int n = arr . length ; int index = binarySearch ( arr , 1 , n - 2 ) ; if ( index != - 1 ) System . out . println ( arr [ index ] ) ; } }