Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

$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|cite|improve this question
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|cite|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.