This function does Binary search for x in i - th row . It does the search from mat [ i ] [ j_low ] to mat [ i ] [ j_high ]
function binarySearch ( mat , i , j_low , j_high , x ) { while ( j_low <= j_high ) { let j_mid = Math . floor ( ( j_low + j_high ) / 2 ) ;