2

This is a recurrence question. I need to solve it using recurrence.

$$T(n)=2T(n−1)+(n-1) \quad T(0) = 0$$

Could somebody please solve it.

p.s: This is not a homework question. My algorithm exams are coming up and I was trying to solve this

Edit: I tried solving this using the recursive approach i.e. substitute the value to T(n-1) and then substitute T(n-1) with T(n-2) and so on and so forth. After this I generalise it using k. Since T(0) = 0, I then equate the generalised term inside T to 0 and solve for k in terms of n. After which I substitute the value of k in the generalised equation leaving me with terms containing n only. However I don't reach the desired solution which is 2ˆn + n - 1

HK Lee
  • 19,964
RDM
  • 179

3 Answers3

1

We have, for $k\ge1$, $$\frac{T_{k}}{2^k}-\frac{T_{k-1}}{2^{k-1}}=\frac{k-1}{2^k}$$ which we can sum from $k=1$ to $k=n$, obtaining by telescoping terms $$\frac{T_{n}}{2^n}-T_{0}=\sum_{k=1}^n\frac{k-1}{2^{k-1}}$$ then use a standard result.

0

at first you must solve the equation $$T(n)=2T(n-1)$$ and then you must try to find a Special part of the inhomogeneous equation. The solution is given by $$T(n)=-1-n+2^n$$

0

Hint: Let $S(n)=T(n)+an+b$. Find $a,b$ such that $S(n)=2S(n-1)$.

lhf
  • 216,483