2

Wikipedia mentions, that from the formula $$ T(n) \leq T(n/5) + T(n\cdot7/10) + c \cdot n $$

one can "easily" show using induction that

$$ T(n) \leq 10 \cdot c \cdot n $$

I am, as it seems, not so smart. So, can anyone tell me how to show this using induction?

user2762996
  • 121
  • 3

2 Answers2

1

Assuming that you got the base covered, here is the inductive step: $$ T(n) \leq T(n/5) + T(7n/10) + cn \leq 10c(n/5) + 10c(7n/10) + cn = 10cn. $$ (Cheating a bit, since $n$ isn't necessarily divisible by 10; but that's a problem in the recurrence.)

You can also just apply the Akra–Bazzi theorem.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503
  • How do you drop the $T(.)$ at the second inequality? – student010101 Mar 14 '21 at 15:11
  • Using the induction hypothesis. – Yuval Filmus Mar 14 '21 at 15:12
  • Ah I see, but how do you even come up with such a hypothesis in the first place? I'm not good at coming up with a possible answer and then going backwards to show that the possible answer is indeed the correct answer. – student010101 Mar 14 '21 at 15:14
  • You get better with experience... Here, we can assume a induction hypothesis of the form $T(n) \leq Mn$, and check for which values of $M$ the inductive step goes through. It turns out that $M=10c$ works. – Yuval Filmus Mar 14 '21 at 15:32
1

I am basically just paraphrasing the steps I've outlined here: https://cs.stackexchange.com/a/83650/68251.

This is assuming the base case is $T(n) \leq c$ when $n < 5$.

Claim

$T(n) \leq 10\cdot c\cdot n$

Proof by Induction (on $n$)

Basis: $n < 5 \implies T(n) \leq c < 10\cdot c < 10\cdot c \cdot n$

Induction: Assume the claim holds for any $n' < n$, we then have

$$\begin{align} T(n) &\leq cn + T(n/5) + T(7n/10)\\ &\leq cn + 10c\cdot n /5 + 10c\cdot 7n /10\\ &= cn + 10c\cdot 9n /10\\ &= 10 \cdot c \cdot n & \square\\ \end{align}$$

ryan
  • 4,501
  • 1
  • 15
  • 41
  • Where does the basis come from? – user2762996 May 21 '20 at 17:08
  • 1
    From the basis in https://cs.stackexchange.com/a/83650/68251. When $n < 5$ we know that $T(n)$ will resolve to some constant because we cannot recurse anymore. This is because $T(5/5) = T(1) = c$. Similarly if we had the recurrence $T(n) = T(n/9) + T(3n/4) + cn$, then the basis would have to be for $n < 9$ for the same reason. – ryan May 21 '20 at 17:39
  • I don't see why we shouldn't be able to recurse anymore. If $n=4$, there is still $T(4 \cdot 7/10)$. – user2762996 May 21 '20 at 17:48
  • 1
    You need a base case to your recurrence, or else you will recurse indefinitely. I have chosen the base case to be $n < 5$. It also doesn't particularly matter that I chose 5. We only need the claim to hold for all $n$ greater than some $n_0$ to show $T(n) = O(n)$. – ryan May 21 '20 at 17:53
  • But with the same method, I could also prove the exact opposite $T(n) \geq 10 \cdot cn$

    Basis: $n < 5 => T(n) \geq 10\cdot cn \geq 10\cdot c \geq c$ And then use the same induction steps with $\geq$ insted of $\leq$

    I guess I just don't understand it, but thanks for the effort anyway.

    – user2762996 May 21 '20 at 18:03
  • For the base case $T(n) \leq c$ when $n < 5$ you could not prove that. I added this detail more explicitly in the answer. – ryan May 21 '20 at 18:05