作者jerry771210 (嘿嘿嘿)
看板NTUE-CS100
標題Re: [課業] 3/17 演算法
時間Wed Mar 18 00:05:54 2009
解三題簡單的:
a. T (n) = 3T (n/2) + n lg n
We have f (n) = nlgn and ( n^log a) = nlg 3 = n^lg3 ≒ n^1.585
b
Since n lg n = O(n^lg 3-ε) for any 0 < ε≦ 0.58
by case 1 of the master theorem, we have
T(n) = θ(n^lg 3)
-------------------------------------------------------------------
b.T (n) = 4T (n/2) + n^2√n
We have f (n) = n^2(√n) = n^5/2 and n^log a = n^log 4 = n^lg 2.
b 2
Since n^5/2 = Ω(n^lg 2+3/2),
we look at the regularity condition in case 3 of the master theorem.
We have af(n/b) = 4(n/2)^2 (√n/2) = (n^5/2)/(√2) ≦ cn^5/2,for 1/√2 ≦ c < 1
Case 3 applies, and we have
T (n) = θ(n^2 √n)
--------------------------------------------------------------------
g.T(n) = T(n-1) + 1/n
This recurrence corresponds to the harmonic series, so that T (n) = Hn,
where Hn = 1/1+1/2+1/3+· · ·+1/n. For the base case, we have T (1) = 1 = H1.
For the inductive step, we assume that T(n-1) = Hn-1, and we have
T (n) = T (n-1) + 1/n
= Hn-1 + 1/n
= Hn
Since Hn = θ(lgn) by equation,we have that
T(n) = θ(lgn).
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.5.53
※ 編輯: jerry771210 來自: 140.112.5.53 (03/18 00:13)
※ 編輯: jerry771210 來自: 140.112.5.53 (03/18 00:15)
→ jerry771210:參考用的 03/18 00:15
推 Kellen310: 噢吼吼吼~~參考一下...我都聽不清楚他說什嚜ˊˋ 03/18 00:18
推 nash3629:幹 還在拼喔 03/18 00:21
→ nash3629:禮拜二晚上是美麗的夜晚ㄋㄟ 03/18 00:21
→ jerry771210:晚點再po f 那題寫法有些複雜 03/18 00:28
推 moonlights:吳季衡超拚的 強 =口= 03/18 00:56