Algorithm analysis

why option c is the answer ? And why not option B ?

• Don't use images as main content of your post. This makes your question impossible to search and inaccessible to the visually impaired; we don't like that. Please transcribe text and mathematics (note that you can use LaTeX) and don't forget to give proper attribution to your sources! – D.W. Jun 18 '18 at 17:47

f will be called many times in this algorithm, as f(c0),f(c1),....
Since 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 f is <= 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.