I am beginning to learn complexity analysis and I can't figure out the overall Big-O complexity of this part of the algorithm, how should this be calculated?
Code Fragment Time Complexity
1 - C = 0 O(1)
2 - while C <= L O(L)
3 - f(C += 1) O(???)
Step 3 in fact takes more steps, but can be summarized as a function f that takes C steps to execute.
My problem is that C is increased with every iteration, so any help or direction on that would be appreciated.
Let's plug a few numbers there and see what happens.
[...]
Let's say "zero steps" is constant time and change it to 1. So there are two ways to answer this:
1 + L * (L + 1) / 2
, so it's O(L2);