I am studying about recurrences using my friend's pdf (Algorithms Unlocked) and trying to solve the problems about recurrences and it is not yet clear to me about the mechanics of the recursion tree(I assume this is the method to be used on this problem) and how to make bounds tight for example I want the constant to be small?
2 Answers
Try to expand your recurence using a recursive tree. You will have something like this:
See that each level has a non-recursive complexity = n By extending T(n), we have 2 subtrees with different heights. You can see the 2 heights H1 and H2.
Now T(n) is bounded by the complexity of the 2 subtrees: n * H1 >= T(n) >= n * H2
Where: H1 = 1+log_2(n) and H2 = 1+log_4(n)
So the solution will be O(nlog_2(n))

- 44
- 2
-
Thank you for the response very simple and precise ! – Simoun Dec 08 '15 at 13:42
-
Sadly enough this does not count as a proof. This is called handwaving in mathematics :-) – Salvador Dali Dec 08 '15 at 20:17
First of all, take a look at the suggestion given here and try to do something before posting the question. I answer this only because I found it interesting to refresh my skills.
The solution is O(n log(n))
.
So you have to see that Master theorem will not work here, but Akra-Bazzi will work.
So here g(n) = n
, a1 = 1
, b1 = 1/2
, a2 = 2
, b2=1/4
. Solving the equation: a1*b1^p + a2*b2^p = 1
you get p = 1
.
Now solving the integral int(1/u)du
from 1
to x
you will get log(x)
. So the complexity is O(x(1+log(x))
which is O(nlog(n))
where O is a tight bound.

- 1
- 1

- 214,103
- 147
- 703
- 753
-
Thanks for the help. I am wondering if recursion tree method will work in this problem ? because in the book only substitution, recursion tree and the master theorem are in the recurrences lesson. thanks – Simoun Dec 08 '15 at 10:47
-
Yes, recursion unrolling would work, I just wanted to practice Akra-Bazzi, because I already unrolled two recursions today. – Salvador Dali Dec 08 '15 at 10:51
-
I see, I just wanna ask if can you use the recursion tree method so I can follow what is happening because I am not familiar with Akra-Bazzi and I am currently learning recursion tree method. Thank you very much – Simoun Dec 08 '15 at 11:11