My background is not CS, but I can provide you with an easy way to look at this problem,
So, I took the paper and pen and started with different values ββof n.
n = 2, cycles = 4 n = 3, cycles = 8 n = 4, cycles = 16 n = 5, cycles = 32.
You can clearly see the cycles = 2 ^ N, and therefore we can conclude that the time complexity of this problem is O (2 ^ N).
Now look at it differently could
We know that
f(0) = 1 f(1) = f(0) + 1 = 2 f(2) = f(1) + f(0) + 1 = 4 ... f(N) = f(N-1) + f(N-2) .. + f(0) + 1 = 2^N.
So, now that you have a repetition ratio similar to how you calculate factorial, you can do the math or create a program to measure the time complexity of the problem.
I hope that my answer will help you understand the theory of calculating time complexity.
source share