0
$\begingroup$

I'm trying to solve this recurrence, but I don't know how to unfold it:
I am looking for a function $T:\mathbb{N}\to\mathbb{N}$ that satisfies $$ T(n)=2 \cdot T\left(\left\lfloor\frac{n+2}{3}\right\rfloor\right) + 1 $$ for all $n\ge4$. The initial values are $T(1)=T(2)=T(3)=1$.


Question: Can I ignore that "$+2$" and solve it as it was $2T(n/3) + 1$?

Note: This comes from a from a problem that uses a V[a..b] array and makes this return:

return V(X) + f(V, a, Y) + f(V, Z, b)

Where $Y$ is $(2a+b)/3$ and $Z$ is $(a+2b)/3$. Hence: $((b-a+3)/3) = ((n+2)/3)$.

  • 0
    Is your recurrence equation complete? Plugging in $n=1$ gives $T(1) = -1$.2017-02-07
  • 0
    When n<=3 f(n) = 1.2017-02-07

2 Answers 2

0

If $n=3^m+1$ then

$$T(n)=T(3^m+1) = 2T(3^{m-1}+1)+1=2^mT(3^0+1)+2^m-1 \\=(n-1)^{\log_3(2)} (T(2)+1)-1$$

and since $\log_3(2)\approx 0.63$ this will be $o(n)$.

With the initial values and rounding, the recurrence is monotonic increasing and so is $o(n)$ in general

0

The substitution $T(n)=2^{f(n)}-1$ shifts the given recurrence into $$f(n)= f\left(\left\lfloor\frac{n+2}{3}\right\rfloor\right) + 1$$ for $n\ge4$, with initial values $f(1)=f(2)=f(3)=1$.

Now you can prove with induction that $f(n)=k$ for all integers $n$ from the range $3^{k-1}

Hence, $f(n)$ grows asymptotically like $\log_3(n)$ and $T(n)$ grows asymptotically like $n^{\log_3(2)}$.