A recursive binary search function . It returns location of x in given array arr [ l . . r ] is present , otherwise - 1
function binarySearch ( arr , l , r , x ) { if ( r < l ) return - 1 ; var mid = l + parseInt ( ( r - l ) / 2 ) ;