📜  门| GATE CS 1999 |第46章

📅  最后修改于: 2021-06-29 05:46:12             🧑  作者: Mango

如果T1 = O(1),请为以下对提供正确的匹配项:

(M) Tn=Tn−1+n           (U) Tn=O(n)
(N) Tn=Tn/2 +n          (V) Tn=O(nlogn)
(O) Tn=Tn/2 +nlogn      (W) T=O(n^2)
(P) Tn=Tn−1 +logn       (X) Tn=O(log^2n) 

(A)兆瓦NV OU PX
(B)兆瓦NU OX PV
[C) MV NW OX PU
(D)兆瓦NU OV PX回答:
解释:

(M) T(n) = T(n-1) + n = 1 + 2 + 3 + … + n = O(n^2) — choice is (W)

(N) T(n) = T(n/2) + n = O(n), using master theorem case -3, - choice is (U)

(O) T(n) = T(n/2) + nlogn = O(nlogn), using master theorem case -3, - choice is (v)

(P) T(n) = T(n-1) + logn = log 1 + log 2 + log 3 + … + log n 
         = log(1*2*3…*n) = log(n!) = nlogn = O(nlogn) - choice is (v) 

因此,没有选项匹配。这个问题的测验