Given two numbers a and b, we have an averaging function (a+b)/2. This function wont work under certain cases. I was supposed to tell the case, and also how to handle it.
Sigiloso
When a and b will be very large values, we would have an overflow. Hence we need to right shift a and b first , i.e a/2 and b/2 , and then add them. However, this wont work if both a and b are odd numbers. In case, if both are odd, then we need to add 1 to the final result eg : a = 5 = 101 b = 3 = 011 ( a >> 1)+ (b >> 1) = 3 . So we add 1 to it. Hence, answer is 4