Rahul-Vijay / C_plus_plus_Algos

Collection of C++ Algorithms for a quick reference. Fork it and start hacking :)
0 stars 32 forks source link

simplification of mid variable calculation #44

Closed zegabr closed 4 years ago

zegabr commented 4 years ago

Explanation for the simplification: l + (r - l)/2 == (2*l + r - l)/2 == (r + l)/2 You can always get mid value of an interval [a,b] by doing (a+b)/2.

Rahul-Vijay commented 4 years ago

Thanks @zegabr