The recurrence T(n) = 2T(n - 1) + n, for n ≥ 2 and T(1) = 1 evaluates to
2n+1 - n - 2
We are given a linear first-order non-homogeneous recurrence relation:
$\qquad T(n) = 2T(n - 1) + n$, for $n \ge 2$
with the base case $T(1) = 1$. We need to find a closed-form expression for $T(n)$.
One common method to solve such recurrence relations is iteration. We repeatedly substitute the definition of $T(n-k)$ into the expression for $T(n)$.
$\qquad T(n) = 2T(n - 1) + n$
$\qquad T(n) = 2[2T(n-2) + (n-1)] + n$
$\qquad T(n) = 2^2 T(n-2) + 2(n-1) + n$
$\qquad T(n) = 2^2[2T(n-3) + (n-2)] + 2(n-1) + n$
$\qquad T(n) = 2^3 T(n-3) + 2^2(n-2) + 2(n-1) + n$
We can see a pattern emerging. After $k$ iterations, the expression for $T(n)$ will be:
$\qquad T(n) = 2^k T(n-k) + \sum_{i=0}^{k-1} 2^i (n-i)$
We continue iterating until we reach the base case $T(1)$. This occurs when $n-k = 1$, which means $k = n-1$. Substituting $k=n-1$ into the general form:
$\qquad T(n) = 2^{n-1} T(n-(n-1)) + \sum_{i=0}^{(n-1)-1} 2^i (n-i)$
$\qquad T(n) = 2^{n-1} T(1) + \sum_{i=0}^{n-2} 2^i (n-i)$
Using the given base case $T(1) = 1$:
$\qquad T(n) = 2^{n-1} \cdot 1 + \sum_{i=0}^{n-2} (n \cdot 2^i - i \cdot 2^i)$
$\qquad T(n) = 2^{n-1} + n \sum_{i=0}^{n-2} 2^i - \sum_{i=0}^{n-2} i \cdot 2^i$
We need to evaluate the two sums:
The first sum is a geometric series with first term $2^0=1$, ratio $2$, and $n-2 - 0 + 1 = n-1$ terms:
$\qquad \sum_{i=0}^{n-2} 2^i = \frac{2^{n-1} - 1}{2 - 1} = 2^{n-1} - 1$
The second sum is $\sum_{i=0}^{n-2} i \cdot 2^i = 0 \cdot 2^0 + 1 \cdot 2^1 + 2 \cdot 2^2 + \dots + (n-2) \cdot 2^{n-2}$. The term for $i=0$ is zero, so this is equivalent to $\sum_{i=1}^{n-2} i \cdot 2^i$.
Let $S = \sum_{i=1}^{m} i x^i$. We can derive the formula for this sum. Consider the geometric series $\sum_{i=0}^{m} x^i = \frac{x^{m+1}-1}{x-1}$. Differentiating with respect to $x$ gives $\sum_{i=1}^{m} i x^{i-1} = \frac{(m+1)x^m(x-1) - (x^{m+1}-1)}{(x-1)^2}$. Multiplying by $x$ gives $\sum_{i=1}^{m} i x^i = x \frac{(m+1)x^m(x-1) - (x^{m+1}-1)}{(x-1)^2}$.
For our sum, $m = n-2$ and $x = 2$. So, $\sum_{i=1}^{n-2} i \cdot 2^i$ is:
$\qquad S_{AG} = \sum_{i=1}^{n-2} i \cdot 2^i = 2 \frac{(n-2+1)2^{n-2}(2-1) - (2^{n-2+1}-1)}{(2-1)^2}$
$\qquad S_{AG} = 2 \frac{(n-1)2^{n-2} \cdot 1 - (2^{n-1}-1)}{1^2}$
$\qquad S_{AG} = 2 [(n-1)2^{n-2} - 2^{n-1} + 1]$
$\qquad S_{AG} = (n-1)2^{n-1} - 2 \cdot 2^{n-1} + 2 \cdot 1$
$\qquad S_{AG} = (n-1)2^{n-1} - 2^n + 2$
Now substitute the results of the sums back into the expression for $T(n)$:
$\qquad T(n) = 2^{n-1} + n (2^{n-1} - 1) - [(n-1)2^{n-1} - 2^n + 2]$
$\qquad T(n) = 2^{n-1} + n 2^{n-1} - n - (n-1)2^{n-1} + 2^n - 2$
$\qquad T(n) = 2^{n-1} + n 2^{n-1} - n - n 2^{n-1} + 2^{n-1} + 2^n - 2$
Combine terms with $2^{n-1}$: $(2^{n-1} + n 2^{n-1} - n 2^{n-1} + 2^{n-1}) = (1+n-n+1)2^{n-1} = 2 \cdot 2^{n-1} = 2^n$.
So, the expression becomes:
$\qquad T(n) = 2^n + 2^n - n - 2$
$\qquad T(n) = 2 \cdot 2^n - n - 2$
$\qquad T(n) = 2^{n+1} - n - 2$
Let's verify this closed form with the base case and a few small values:
The formula $T(n) = 2^{n+1} - n - 2$ correctly evaluates the recurrence relation.
Comparing our derived closed form $T(n) = 2^{n+1} - n - 2$ with the given options, we find it matches one of them.
| Option | Expression | Matches Derived Formula? |
|---|---|---|
| 1 | $2^n - n$ | No |
| 2 | $2^{n+1} - n - 2$ | Yes |
| 3 | $2^n + n$ | No |
| 4 | $2^{n+1} - 2n - 2$ | No |
The closed form $T(n) = 2^{n+1} - n - 2$ is the correct evaluation of the given recurrence relation.
| Concept | Description | Example |
|---|---|---|
| Recurrence Relation | An equation that defines a sequence where each term is defined as a function of the preceding terms. | $T(n) = T(n-1) + T(n-2)$ (Fibonacci) |
| Base Case | A starting value(s) for the recurrence, needed to terminate the recursion and define the sequence uniquely. | $T(1)=1, T(2)=1$ for Fibonacci |
| Linear Recurrence | Each term is a linear function of previous terms (no products like $T(n-1)T(n-2)$). | $T(n) = a T(n-1) + b T(n-2) + f(n)$ |
| Homogeneous Recurrence | The equation only involves terms of the sequence itself ($f(n)=0$). | $T(n) = a T(n-1) + b T(n-2)$ |
| Non-Homogeneous Recurrence | The equation includes an extra term dependent on $n$ ($f(n) \ne 0$). | $T(n) = a T(n-1) + b T(n-2) + f(n)$ (like the question's $T(n) = 2T(n-1) + n$) |
| Solving Recurrences | Finding a closed-form expression for $T(n)$ that does not depend on previous terms. Methods include iteration, substitution, characteristic equations (for linear homogeneous), master theorem (for divide & conquer). | Finding $T(n) = 2^{n+1} - n - 2$ for the given recurrence. |
Linear non-homogeneous recurrence relations of the form $T(n) = a T(n-1) + f(n)$ can also be solved using the method of finding a homogeneous solution and a particular solution.
1. Homogeneous Solution ($T_h(n)$): Solve the associated homogeneous recurrence $T_h(n) = a T_h(n-1)$. The characteristic equation is $r - a = 0$, so $r=a$. The homogeneous solution is $T_h(n) = C \cdot a^n$ for some constant $C$. In our case, $a=2$, so $T_h(n) = C \cdot 2^n$.
2. Particular Solution ($T_p(n)$): Guess a form for $T_p(n)$ based on the non-homogeneous term $f(n)$. Since $f(n) = n$ (a linear polynomial in $n$), we guess a particular solution of the form $T_p(n) = An + B$. Substitute this into the original recurrence:
$\qquad An + B = 2(A(n-1) + B) + n$
$\qquad An + B = 2An - 2A + 2B + n$
$\qquad An + B = (2A + 1)n + (2B - 2A)$
Equating coefficients of $n$ and constant terms:
So the particular solution is $T_p(n) = -n - 2$.
3. General Solution: The total solution is the sum of the homogeneous and particular solutions: $T(n) = T_h(n) + T_p(n) = C \cdot 2^n - n - 2$.
4. Using Base Case to Find C: Use the base case $T(1) = 1$ to find $C$:
$\qquad T(1) = C \cdot 2^1 - 1 - 2 = 1$
$\qquad 2C - 3 = 1$
$\qquad 2C = 4$
$\qquad C = 2$
Substituting $C=2$ back into the general solution:
$\qquad T(n) = 2 \cdot 2^n - n - 2$
$\qquad T(n) = 2^{n+1} - n - 2$
This confirms the result obtained by the iteration method.
Every bounded sequence has a cluster point; then this theorem is known as:
In an experiment, positive and negative values are equally likely to occur. The probability of obtaining at most one negative value in five trials is
______ is a machine that converts mechanical energy into electrical energy.