3 回答

TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超6個(gè)贊
Fib(n)
Fib(n-1)
Fib(n-2)
O(1)
Fib(n)
T(n<=1) = O(1)
T(n) = T(n-1) + T(n-2) + O(1)
n
O(2
n
)
n = 1
T(n-1) = O(2
n-1
)
, 因此
T(n) = T(n-1) + T(n-2) + O(1)
等于
T(n) = O(2
n-1
) + O(2
n-2
) + O(1) = O(2
n
)
Fib(n)
f(n) = f(n-1) + f(n-2)
.
Fib(n)
T(n)
Fib(n) x O(1)
θ(1.6
n
)

TA貢獻(xiàn)1995條經(jīng)驗(yàn) 獲得超2個(gè)贊
F(n)
F(1)
1
F(n)
F(n-1) + F(n-2)
.
an
a2
a
(1+sqrt(5))/2 = 1.6180339887
添加回答
舉報(bào)