New answers tagged efficiency
18
It's called "loop fusion".
It's often more efficient, in the sense of doing more work per loop iteration and sometimes (as you say) other advantages. On the other hand, the fused loop in your example may also put more pressure on the CPU's cache prefetch system. So do test it before declaring it more efficient.
Top 50 recent answers are included
Related Tags
efficiency × 260algorithms × 143
data-structures × 40
sorting × 25
graphs × 20
time-complexity × 14
complexity-theory × 13
algorithm-analysis × 11
reference-request × 11
optimization × 10
arrays × 10
dynamic-programming × 9
combinatorics × 8
asymptotics × 7
runtime-analysis × 7
search-algorithms × 7
strings × 7
computational-geometry × 6
shortest-path × 6
parallel-computing × 6
arithmetic × 6
integers × 6
terminology × 5
dictionaries × 5
priority-queues × 5