Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

$A({n})=A(\lfloor{n/2} \rfloor)+n^2$ for $n>1$

$A({n})=1$ for $n=0,1$

Will above recursion ends in $\Theta(n^2)$ time?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

If by "ends in $\Theta(n^2)$ time" you mean that the (naive) evaluation of $A(n)$ requires $\Theta(n^2)$ evaluations of $A$, then no. In fact, it takes only $\lfloor \log_2 n \rfloor + 1 = \Theta(\log n)$ evaluations (for $n \ge 2$).

Specifically, it's easy to show by induction on $k$ that naive evaluation of $A(n)$ takes $k$ evaluations for all $2^{k-1} \le n < 2^k$, $k \ge 2$.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.