In this article: http://googleresearch.blogspot.sg/2006/06/extra-extra-read-all-about-it-nearly.html, it mentioned most quick sort algorithm had a bug (left+right)/2, and it pointed out that the solution was using left+(right-left)/2
instead of (left+right)/2
.
The solution was also given in question Bug in quicksort example (K&R C book)?
My question is why left+(right-left)/2
can avoid overflow? How to prove it? Thanks in advance.