You are on page 1of 3

Practice Sets

1. Prove that the solution of is


2. Find the solution of the recurrence relation

3. Show that the solution of is


4. Show that the solution of is

5. Find the solution of


Prove that the solution of is

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

When 𝑛 = 1, we assume 𝑇 1 = 0 (assuming base


condition)
Find the solution of the recurrence relation

𝑇 𝑛 = 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 ∗𝑇 𝑛 + 𝑘 ∗ 𝑙𝑜𝑔 𝑛

We assume 𝑛 = 2,𝑇 2 = 1 (assuming base case)


2 = log 𝑛
𝑘 = log log 𝑛
𝑇 𝑛 = log 𝑛 ∗ 𝑇 2 + log log 𝑛 ∗ log 𝑛
= log 𝑛 ∗ 1 + log log 𝑛 ∗ log 𝑛 = 𝑂(log log 𝑛 ∗ log 𝑛)

You might also like