Skip to main content
added 515 characters in body
Source Link
nir shahar
  • 11.7k
  • 3
  • 16
  • 35

Since the OP made a writing mistake in the question, I will keep the first answer and add onto it the correct one.


For $T(n)=2+2T(n/2):$

I believe that the recurrence relation is not $O(\sqrt{n})$, and in fact is $\Theta(n)$.

We can see this easily using the master theorem, where here $a = 2, b = 2, f(n)= 2$, and then $T(n) = aT(n/b) + f(n)$.

Since $f(n)=O(n^{\log_b (a)})=O(n)$ then by the first case in the master theorem we have $T(n) = \Theta(n^{\log_b (a)}) = \Theta(n)$.


For $T(n)=2+2T(n/4)$:

As I have mentioned in the previous proof, the master theorem is useful for solving such recurrence formula. In our case, we have $a=2,b=4,f(n)=2$ and thus $\log_b(a)=\log_4(2) = 0.5$

By the first case of the master theorem, since $f(n)=O(n^{\log_b(a)})=O(n^{0.5})=O(\sqrt n)$ then we will also have $T(n) = \Theta(\sqrt n)$

I believe that the recurrence relation is not $O(\sqrt{n})$, and in fact is $\Theta(n)$.

We can see this easily using the master theorem, where here $a = 2, b = 2, f(n)= 2$, and then $T(n) = aT(n/b) + f(n)$.

Since $f(n)=O(n^{\log_b (a)})=O(n)$ then by the first case in the master theorem we have $T(n) = \Theta(n^{\log_b (a)}) = \Theta(n)$.

Since the OP made a writing mistake in the question, I will keep the first answer and add onto it the correct one.


For $T(n)=2+2T(n/2):$

I believe that the recurrence relation is not $O(\sqrt{n})$, and in fact is $\Theta(n)$.

We can see this easily using the master theorem, where here $a = 2, b = 2, f(n)= 2$, and then $T(n) = aT(n/b) + f(n)$.

Since $f(n)=O(n^{\log_b (a)})=O(n)$ then by the first case in the master theorem we have $T(n) = \Theta(n^{\log_b (a)}) = \Theta(n)$.


For $T(n)=2+2T(n/4)$:

As I have mentioned in the previous proof, the master theorem is useful for solving such recurrence formula. In our case, we have $a=2,b=4,f(n)=2$ and thus $\log_b(a)=\log_4(2) = 0.5$

By the first case of the master theorem, since $f(n)=O(n^{\log_b(a)})=O(n^{0.5})=O(\sqrt n)$ then we will also have $T(n) = \Theta(\sqrt n)$

Source Link
nir shahar
  • 11.7k
  • 3
  • 16
  • 35

I believe that the recurrence relation is not $O(\sqrt{n})$, and in fact is $\Theta(n)$.

We can see this easily using the master theorem, where here $a = 2, b = 2, f(n)= 2$, and then $T(n) = aT(n/b) + f(n)$.

Since $f(n)=O(n^{\log_b (a)})=O(n)$ then by the first case in the master theorem we have $T(n) = \Theta(n^{\log_b (a)}) = \Theta(n)$.