0

I need to prove by induction that for -

T(n) = T(n-1) + c2 , T(1) = c1 

The run time complexity is - T(n) = O(n)

In my induction step after the base case and the induction assumption I wrote that -

T(k+1) = T(k) + c2 = O(k) + c2 = O(k + 1)

but for proving this run time complexity I need to show that there exist C,N0 > 0 so the final inequality true.

If someone can tell me how to find/or correct my induction. Thanks.

Barak Mi
  • 51
  • 6

1 Answers1

2

To prove by induction, you have to do three steps.

  1. define proposition P(n) for n

  2. show P(n_0) is true for base case n_0

  3. assume that P(k) is true and show P(k+1)is also true

it seems that you don't have concrete definition of your P(n).

so Let P(n) := there exists constant c(>0) that T(n) <= c*n.

and your induction step will be like this:

assume that P(k)is true. then P(k+1) = T(k) + c2

by P(k), there exists constant c_k(>0) that T(k) <= c_k*k.

so T(k+1) = T(k) + c2 <= c_k*k + c2 <= (c_k+1)*k + (c_k+1) = (c_k+1)*(k+1) (if we choose c_k+1 = max(c_k, c2))

so P(k+1)is true.

therefore these proves by induction that

for every n > n_0=1, there exists constant c(>0) that T(n) <= c*n.

P.S. here you can get some readings on induction. and also, at MIT OCW, the course 6042J provides nice lecture for induction and strong induction you can practice and get intuition.

kidkkr
  • 457
  • 3
  • 16