3 ms·
I love this idea. I've had to make this decision before (one or two passes). Now I'll do two passes for readability and stick this comment in my code: // Daddy
by copperx 4y ago
I love this idea. I've had to make this decision before (one or two passes). Now I'll do two passes for readability and stick this comment in my code:
// Daddy, chill. Two passes are still O(N).
- quickthrower2 4y ago// O notation is another example of what you measure, you get // Got a performance issue, hide it in the constant, don't expose it in the f(N) :-)
- xg15 4y agoTwo passes can be far more efficient if you take memory layout and pagefaults into account. Same logic as to why you can assemble a set of identical pieces of IKEA furniture faster if you first do step 1 for all pieces, then step 2 for all pieces etc, than if you assemble the pieces one by one.