2 ms·
Don't some of these examples run in O(1) time because the value in the loop isn't used? E.g in the first example 0 is returned instead of the sum. Obviously we
by alkonaut 10y ago
Don't some of these examples run in O(1) time because the value in the loop isn't used? E.g in the first example 0 is returned instead of the sum.
Obviously we are talking about real world c compilers with real world optimizations so presumably we'd have to also consider whether the loop is executed at all?