I heard that, when computing mean value, start+(end-start)/2 differs from (start+end)/2 because the latter can cause overflow. I do not quite understand why this second one
In Binary Search, we will write the following code:
if(start > end){ return; } int mid = start + (end - start) / 2;
By using start + (end - start) / 2, we can avoid the problems which are pointed by @dasblinkenlight
start + (end - start) / 2
if we use (start + end) / 2, it will overflow as shown by dasblinkenlight
(start + end) / 2