本文内容:http://googleresearch.blogspot.sg/2006/06/extra-extra-read-all-about-it-nearly.html,它提到最快速排序算法有一个bug(左+右)/ 2 ,它指出解决方案是使用left+(right-left)/2而不是(left+right)/2.在快速排序示例(K&R C book)中也给出了问题Bug的解决方案?
left+(right-left)/2
(left+right)/2
我的问题是为什么left+(right-left)/2可以避免溢出?怎么证明呢?提前致谢.
integer-overflow
integer-overflow ×1