why option c is the answer ? And why not option B ?
f will be called many times in this algorithm, as
counter is reset to
0 after each call to
f, we get that
c0+c1+... <= n. Since
f has a linear cost, the cumulative cost of all the calls to
<= k c0 + k c1 + ... = k n for some constant
k. Hence this cost is $O(n)$.
The rest of the program only adds $O(n)$ more operations, so we get $O(n)$ overall cost. Since the loop takes $\Omega(n)$ iterations, we also get $\Theta(n)$ overall cost.