Search function for searching the first element of the subarray which is greater or equal to the last element ( num )
int binarySearch ( int * searchSpace , int s , int e , int num ) { int ans ; while ( s <= e ) { int mid = ( s + e ) / 2 ; if ( searchSpace [ mid ] >= num ) { ans = mid ; e = mid - 1 ; } else s = mid + 1 ; } return ans ; }