(n - Multiplication) vs (n/2 - multiplication + 2 additions) which is better?
问题 I have a C program that has n multiplications (single multiplication with n iterations) and I found another logic that has n/2 iterations of (1 multiplication + 2 additions). I know about the complexity that both are of O(n). but in terms of CPU cycles. which is faster ? 回答1: First of all follow Dietrich Epp's first advice - measuring is (at least for complex optimization problems) the only way to be sure. Now if you want to figure out why one is faster than the other, we can try. There are