Driver program
public static void Main ( ) { int [ ] arr = { 6 , 7 , 8 , 11 , 9 , 5 , 2 , 1 } ; int n = arr . Length ; int index = binarySearch ( arr , 1 , n - 2 ) ; if ( index != - 1 ) Console . Write ( arr [ index ] ) ; } }