-2

$$T(n) = 2T(n/2) + \Theta(n), n > 1$$ $$T(n) = \Theta (1), n \le 1$$

$$G(n) = G(\lfloor n/2 \rfloor) + G (\lceil n/2 \rceil) + \Theta(n), n > 1$$ $$G(n) = \Theta (1), n \le 1$$

Prove $T(n)$ and $G(n)$ have the same asymtotic running time.

I tried using the sandwich theorem but got nowhere. Please be really explicit and show all your steps in your answer. Thank you.

2 Answers2

4

Hint: Start by replacing $\Theta(n)$ with $n$ and $\Theta(1)$ by $1$. Prove by induction that $$G(2^{\lfloor \log_2 n \rfloor}) \leq G(n) \leq G(2^{\lceil \log_2 n \rceil}).$$ Prove that $G(2^n) = F(2^n)$, and solve the recurrence for $F$. Conclude that $G(n) = \Theta(F(n))$.

If you want to be completely formal, you'll have to address the $\Theta(n)$ and $\Theta(1)$ summands. The idea is to replace $\cdots = \cdots + \Theta(n)$ with $\cdots \geq \cdots + cn$ and $\cdots \leq \cdots + Cn$, and then compute lower and upper bounds on $G$.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
4

To prove that both recurrences have the same asymptotic growth, solve both. These are very classical examples of recurrences, for example showing up in the analysis of mergesort. You could use the Master Theorem, but it is even easier to have a look at the recursion trees. For both recurrences you have almost the same situation: There are $n$ "elements" for every level of the tree, and we have $\Theta(\log n)$ levels. Such every level contributes $c\cdot n$, where $c$ is the constant of the $\Theta(n)$, which gives in both cases a growth rate of $\Theta(n \log n)$.

A.Schulz
  • 12,167
  • 1
  • 40
  • 63