KonkurStudy
همه کارت‌ها

Subtract-and-Conquer Recurrence Growth

When the argument shrinks by a constant (n-1) instead of a factor, unroll the recurrence; a branching factor a>1 gives exponential growth Θ(an)\Theta(a^n).

کارت مفهوم کنکور ارشد علوم کامپیوتر

اهمیت
۰/۵

Intuition

A recurrence like T(n)=aT(n−b)+f(n)T(n)=aT(n-b)+f(n) is subtract-and-conquer: the argument decreases by a fixed amount bb, not by a dividing factor. The Master Theorem (built for T(n)=aT(n/b)+f(n)T(n)=aT(n/b)+f(n)) does not apply. Instead, unroll level by level. The recursion has depth ≈n/b\approx n/b, and each level multiplies the count of subproblems by aa, so the leaf count is an/ba^{n/b}.

Result / Method

For T(n)=aT(n−1)+dT(n)=aT(n-1)+d (constant dd):

  • If a=1a=1: T(n)=Θ(n)T(n)=\Theta(n) (just adding dd at each of nn levels).
  • If a>1a>1: T(n)=Θ(an)T(n)=\Theta(a^n), exponential. The geometric sum is dominated by its largest term.

General pattern: T(n)=aT(n−b)+Θ(nk)T(n)=aT(n-b)+\Theta(n^k) gives Θ(nk)\Theta(n^k) if a<1a<1... but for the konkur case a≥2a\ge 2 the answer is exponential, Θ(an/b)\Theta(a^{n/b}).

Worked example (Q68)

Given T(1)=cT(1)=c, T(n)=2T(n−1)+dT(n)=2T(n-1)+d. Unroll:

T(n) = 2T(n-1) + d
     = 4T(n-2) + 2d + d
     = 8T(n-3) + 4d + 2d + d
     = ...
     = 2^(n-1) T(1) + d * (2^(n-1) - 1)
     = (c+d) * 2^(n-1) - d

The geometric sum ∑i=0n−22i=2n−1−1\sum_{i=0}^{n-2}2^i = 2^{n-1}-1. Since c,dc,d are constants, T(n)=Θ(2n)=O(2n)T(n)=\Theta(2^n)=O(2^n).

Pitfall: Do not confuse T(n)=2T(n−1)+dT(n)=2T(n-1)+d (argument decreases by 1 -> Θ(2n)\Theta(2^n), exponential) with T(n)=2T(n/2)+dT(n)=2T(n/2)+d (argument halved -> Θ(n)\Theta(n) by the Master Theorem). The minus sign versus division completely changes the growth rate.

فرمول‌های کلیدی

Subtract-and-conquer doubling
T(n)=2T(n−1)+d  ⇒  T(n)=(c+d) 2n−1−d=Θ(2n)T(n)=2T(n-1)+d \;\Rightarrow\; T(n)=(c+d)\,2^{n-1}-d=\Theta(2^n)

Unrolling a recurrence whose argument drops by 1 and branches by 2; closed form is exponential.

Geometric sum of work
∑i=0n−22i=2n−1−1\sum_{i=0}^{n-2}2^{i}=2^{n-1}-1

The accumulated additive cost across levels; dominated by its top term, giving $\Theta(2^n)$.

General subtract recurrence
T(n)=aT(n−b)+f(n)  ⇒  Θ(an/b) when a>1T(n)=aT(n-b)+f(n)\;\Rightarrow\;\Theta(a^{n/b}) \text{ when } a>1

Depth n/b with branching a yields a^{n/b} leaves; exponential growth, Master Theorem inapplicable.

#recurrence-relation#asymptotic-analysis#subtract-and-conquer#exponential-growth#substitution-method

سوالات تمرینی