0

I've been learning master theorem in school now and have learnt how to apply it to a number of recurrence relations. However one of my assignments has the following recurrence relation:

T(n) = T(n-2) + n^2

Am I wrong in thinking that I cannot apply Master Theorem to this equation? If it can be applied, I am unsure how, as the variable T(n-2) gives no value for "b" which would usually be used to solve with master theorem.

If it can be solved with Master Theorem, how would it be solved? If it cannot be, how would one go about solving this specific recurrence relation?

Thank you in advance for any help and clarification!

keenns
  • 111
  • 1
  • 5

4 Answers4

3

Think about what the derivative of T is. If the difference between T (n) and T (n-2) is $n^2$ then the derivative T' (n) is about $n^2 / 2$ and T (n) is about $2/3 ยท n^3$.

gnasher729
  • 32,238
  • 36
  • 56
2

Don't use the Master theorem for this recurrence. Instead, use guess-and-prove, expand a few times and spot the pattern, or express it as a summation.

D.W.
  • 167,959
  • 22
  • 232
  • 500
1

If in the form:

$T(n) = aT(n-b)+f(n) ,\hspace{0.5cm} if \hspace{0.5cm}n>1,\hspace{0.5cm}a>0,\hspace{0.5cm}b>0,\hspace{0.5cm}k>=0$

and if $f(n)$ is $O(n^k)$ then

$T(n)=O(n^k) \hspace{0.5cm} if \hspace{0.5cm} a<1$

$T(n)=O(n^{k+1}) \hspace{0.5cm} if \hspace{0.5cm} a=1$

$T(n)=O(n^k.a^{n/b}) \hspace{0.5cm} if \hspace{0.5cm} a>1$

Alwyn Mathew
  • 551
  • 2
  • 13
-1

This: Solving Recurrence Relations 'Chip & Conquer' helped me solve the relation.

keenns
  • 111
  • 1
  • 5