My friends and I are having trouble resolving this...
T1 = 1,
T(n) = 2T(n/2) + 1, n > 1.
I would appreciate if anyone could help us solve this, and explain how to.
My friends and I are having trouble resolving this...
T1 = 1,
T(n) = 2T(n/2) + 1, n > 1.
I would appreciate if anyone could help us solve this, and explain how to.
Hints:
Considering $n = 2^m$ we have
$$ T\left(2^m\right)=2T\left(2^{m-1}\right)+1 $$
now calling $\mathbb{T}(\cdot)=T\left(2^{(\cdot)}\right)$ we have
$$ \mathbb{T}(m)= 2\mathbb{T}(m-1)+1 $$
this linear recurrence has as soluttion
$$ \mathbb{T}(m)= c_0 2^{m-1}+2^m - 1 $$
or equivalently
$$ T\left(2^m\right)=c_0 2^{m-1}+2^m - 1 $$
then
$$ T(n) = c_0 \frac n2 + n - 1 = c_1 n -1 $$
but $T(1) = c_1-1=1\Rightarrow c_1 = 2$ hence
$$ T(n) = 2n-1 $$