Function to perform binary search on an array sorted in increasing order l and r represent the left and right index of the row to be searched
function binarySearchRowInc ( arr , row , l , r , x ) { while ( l <= r ) { var mid = parseInt ( ( l + r ) / 2 ) ; if ( arr [ row ] [ mid ] == x ) return mid ; if ( arr [ row ] [ mid ] < x ) l = mid + 1 ; else r = mid - 1 ; } return - 1 ; }