Professional Documents
Culture Documents
Solving ,
𝑛 𝑛 We need to find when = 1, which implies
𝑇 𝑛 = 2 ∗ 2𝑇 + +𝑛
4 2 𝑘 = log 𝑛
𝑛
=2 ∗𝑇 +𝑛+𝑛
4
𝑛 𝑛 𝑇 𝑛 =2 ∗ 𝑇 1 + 𝑛 ∗ log 𝑛
= 2 ∗ 2𝑇 + + 2𝑛
8 4 = 𝑛 ∗ 𝑇 1 + 𝑛 ∗ log 𝑛
𝑛
=2 ∗𝑇 + 3𝑛 = 𝑛 ∗ 0 + 𝑛 ∗ log 𝑛
8 = 𝑛 ∗ log 𝑛
Continue up to 𝑘 times, we get
𝑛
𝑇 𝑛 =2 𝑇 +𝑘∗𝑛 Therefore, the solution of 𝑇 𝑛 = 𝑂 𝑛𝑙𝑜𝑔 𝑛
2
𝑇 𝑛 = 2∗𝑇 𝑛 + log 𝑛
=2∗ 2∗T n + log n + log n
2
=2 ∗𝑇 𝑛 + log 𝑛 + log 𝑛
2
=2 ∗𝑇 𝑛 + 2 log 𝑛
Continue up to 𝑘 times, we get
𝑇 𝑛 =2 ∗𝑇 𝑛 + 𝑘 ∗ 𝑙𝑜𝑔 𝑛