Consider the recurrence T(n)={(c, text(if) quad n quad text(is) quad 1),(T(lfloor(n/2)rfloor)+T(lfloor(n/4)rfloor)+4n, text(if) quad n quad text(is)>1):} A. Express the cost of all levels of the recursion tree as a sum over the cost of each level of the recursion tree B. Give a function g(n) and show that it is an upper bound on the sum
Baqling
Answered question
2022-09-04
Consider the recurrence A. Express the cost of all levels of the recursion tree as a sum over the cost of each level of the recursion tree B. Give a function g(n) and show that it is an upper bound on the sum
Answer & Explanation
yamalwg
Beginner2022-09-05Added 17 answers
Step 1 Suppose we start by solving the following recurrence:
where and . Now let
be the binary representation of n. We unroll the recursion to obtain an exact formula for . We recognize the generating function of the Fibonacci numbers, so the formula becomes . We now compute lower and upper bounds which are actually attained and cannot be improved upon. For the lower bound consider a one digit followed by a string of zeroes, to give . Now since
the sum term converges to a number, we have . For an upper bound consider a string of one digits to get . The same constant appears as in the lower bound. Now since the term is asymptotically dominated by (we have because ) joining the upper and the lower bound we get for the asymptotics of this recurrence that it is , which, let it be said, could also have been obtained by inspection. Remark. The evaluation of the constant is done by noting that the generating function of which at evaluates to . We have a certain flexibility as to what power of two to use in the constant but this does not affect the asymptotics. This MSE link has a similar calculation.
William Collins
Beginner2022-09-06Added 12 answers
Step 1 Inductive Hypothesis: for for some constant . Then, prove the inductive step:
Where is true if which works when . So, the moral of the story is that if you can guess that it is not hard to prove it by induction. EDIT: One final note, it wasn't asked to get a bound on T(n), but it is pretty clear (by the recurrence) that since . Then, combining this with the previous argument shows that .