1
$\begingroup$

I have the below recurrence: \begin{align} T(n, 1) &= 3n \\ T(1, m) &= 3m \\ T(n, m) &= 3n + T(\tfrac{n}{3}, \tfrac{m}{3}) \end{align}

How to get a tight asymptotic bound for $T(n, n^2)$ assuming that $n$ is a power of 3?

Using the substitution method for $T(m,n)$, I get a very weird relation:

$$T(n,m) = 3n + \frac{m}{3^{k-1}} + n\left(3 - \frac{1}{3^{k-1}}\right),$$ where $k = \log_3 n$.

Any suggestion would be helpful.

$\endgroup$
2
  • $\begingroup$ Welcome to the site! What's $k$? $\endgroup$ Commented Sep 21, 2021 at 19:46
  • $\begingroup$ Your solution cannot be right. Plugging $m=1$, you don't get $3n$. $\endgroup$
    – user16034
    Commented Jun 20, 2022 at 8:01

1 Answer 1

1
$\begingroup$

Let $S(N,M) = T(3^N,3^M)/3$. If $N \geq M$ then \begin{align} S(N,M) &= 3^N + S(N-1,M-1) \\ &= 3^N + 3^{N-1} + S(N-2,M-2) + \\ &= \cdots \\ &= 3^N + \cdots + 3^{N-M+2} + S(N-M+1,1) \\ &= 3^N + \cdots + 3^{N-M+1}. \end{align} Similarly, if $N \leq M$ then \begin{align} S(N,M) &= 3^N + S(N-1,M-1) \\ &= 3^N + 3^{N-1} + S(N-2,M-2) + \\ &= \cdots \\ &= 3^N + \cdots + 3^{N-M+2} + S(1,M-N+1) \\ &= 3^N + \cdots + 3^{N-M+2} + 3^{M-N+1}. \end{align} It follows that $$ S(N,M)= \Theta(3^N + 3^{M-N}), $$ and so $$ T(n,m) = \Theta(n + m/n). $$ In particular, $$ T(n,n^2) = \Theta(n). $$

$\endgroup$
2
  • $\begingroup$ The recurrence is really strange. It seems that T(n, n^4) = O(n^3), but T(n^2, n^4) is only O (n^2). Or T(x, y) = O (max (x, y/x)). $\endgroup$
    – gnasher729
    Commented Sep 22, 2021 at 9:13
  • $\begingroup$ Indeed, $O(f + g)$ is the same as $O(\max(f,g))$. $\endgroup$ Commented Sep 22, 2021 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.