Finding the maximum among left and right child
return max ( rangeMax ( l , r , arr , 2 * i + 1 , sl , Math . floor ( ( sl + sr ) / 2 ) ) , rangeMax ( l , r , arr , 2 * i + 2 , Math . floor ( ( sl + sr ) / 2 ) + 1 , sr ) ) ; } function max ( f , s ) { if ( f . first > s . first ) return f ; else return s ; }