The time complexity of the following program is:

int fib (int x) {
if (x < 2)

return 1;

return x times x times fib (Xmur1)
}

what is the time complexity of this program?

Aug.13,2021

it's probably like this (less confident about your math level)
n n ((n Mel 1) (n Mel 1)) ((n Mel 2) (n Mel 2)). 2 2 1
= n! n!
= n! ^ 2

) Every time

n increases by 1, the operation that needs to be added is fixed, so it is linear correlation. The complexity of linear correlation O=kN in the algorithm, k can basically be ignored, so the time complexity we think it is O (n) is fine.

Menu