function to find index of element ' x ' in sorted ' arr ' uses binary search technique
int binarySearch ( int arr [ ] , int low , int high , int x ) { while ( low <= high ) { int mid = ( low + high ) / 2 ; if ( arr [ mid ] == x ) return mid ; else if ( arr [ mid ] > x ) high = mid - 1 ; else low = mid + 1 ; } }