Return the lower bound i . e smallest index of element having value greater or equal to value
function binary_lower ( value , arr , n ) { var start = 0 ; var end = n - 1 ; var ans = - 1 ; var mid ; while ( start <= end ) { mid = parseInt ( ( start + end ) / 2 ) ; if ( arr [ mid ] >= value ) { end = mid - 1 ; ans = mid ; } else { start = mid + 1 ; } } return ans ; }