edited by
1,649 views
2 votes
2 votes

What to use for this Master or Substitution Method ?

T(1) = 1, and for all n ≥ 2 a power of 2, T(n)=2T(n/2) + 6n − 1.

If it is possible in Master Method how ?

Even,Substitution is also accecpted here.

Edit: In substitution Method

Suppose T(1) = 1, and for all n ≥ 2 a power of 2, T(n)=2T(n/2) + 6n − 1.

If n is large enough, then by repeated substitution,

T(n)=2T(n/2) + 6n − 1 (after one substitution)

= 2(2T(n/4) + 6n/2 − 1) + 6n − 1

= 4T(n/4) + (6n − 2) + (6n − 1) (after two substitutions)

= 4(2T(n/8) + 6n/4 − 1) + (6n − 2) + (6n − 1)

= 8T(n/8) + (6n − 4) + (6n − 2) + (6n − 1) (after three substitutions).

Therefore, after i substitutions,

$T(n) = 2^{i}T(n / 2^{i}) + 6in - \left ( \sum_{j = 0}^{i -1} 2^j\right )$

This can be verified easily by induction. Hence, taking i = log n,

$T(n) = nT(1) + 6nlogn - \left ( \sum_{j = 0}^{logn -1} 2^j\right )$

= n + 6n log n − (2log n − 1)

= 6n log n + 1.

edited by

2 Answers

2 votes
2 votes

given  Recurrence satisfy aT(n/b) + f(n) where a>=1, b>1, f(n) is polynomial of 'n'.

here a=2, b=2, f(n) = 6n-1 (Linear function in 'n')
Apply masters answer is Θ(nlogn).
https://en.wikipedia.org/wiki/Master_theorem

0 votes
0 votes
Yes i think possible . Replace the term 6n - 1 with some function say f(n)

Now expression becomes  :

T(N) = 2T(N/2) + f(n) where f(n) is O(n) because dominating factor in this polynomial function is n.

T(N) = 2T(N/2) + O(N)

Now apply Master's Method :

Ans is  $\Theta$ (nlogn) .

Related questions

0 votes
0 votes
1 answer
1
1 votes
1 votes
1 answer
2
1 votes
1 votes
1 answer
3
1 votes
1 votes
2 answers
4
mdboi asked Oct 28, 2022
742 views
how do i apply master theorem to this? T(n)=2T(n/2)−n^3n