Recurrence Relations and Generating Functions

Learn to describe counting problems with recurrence relations and to solve them. Find closed forms for linear recurrences with constant coefficients, both homogeneous and nonhomogeneous, analyze divide-and-conquer recurrences such as merge sort with the master theorem, and use generating functions to count selections and solve recurrences. Finish with inclusion–exclusion, which counts overlapping sets, onto functions and derangements.

IntermediateLesson 8 of 10 in Discrete Mathematics Course

What you will learn

  1. Describe a sequence by a recurrence relation and initial conditions, compute and solve simple recurrences by iteration, and build recurrences that count strings, tilings, regions and other structures.
    • Compute and solve simple recurrences
      Read a recurrence relation with its initial conditions, compute terms, check a proposed solution, find a closed form by iteration and prove it by induction.
    • Build recurrences that count
      Set up a recurrence for a counting problem by splitting the objects of size n into cases built from smaller objects, find the initial conditions, and check the result on small cases.
  2. Find closed forms for linear recurrences with constant coefficients: homogeneous ones with distinct or repeated characteristic roots, and nonhomogeneous ones by adding a particular solution.
    • Solve homogeneous recurrences with distinct roots
      Recognize a linear homogeneous recurrence with constant coefficients, form its characteristic equation and solve it when the characteristic roots are distinct.
    • Solve recurrences with repeated roots
      Write the general solution when a characteristic root is repeated, fit it to initial conditions, and combine roots of any multiplicity.
    • Solve nonhomogeneous recurrences
      Solve a linear recurrence with an added term F(n) by combining a particular solution with the general solution of the associated homogeneous recurrence, then fitting the initial conditions.
  3. Write recurrences for algorithms that split a problem into smaller copies of itself, solve them exactly for powers of the split factor, and estimate their growth with the master theorem.
    • Set up and unroll divide-and-conquer recurrences
      Turn a divide-and-conquer algorithm into a recurrence of the form f(n) = a f(n/b) + g(n) and solve it exactly when n is a power of b.
    • Estimate growth with the master theorem
      Apply the master theorem to recurrences of the form f(n) = a f(n/b) + c n^d, explain its three cases, and recognize recurrences it does not cover.
  4. Encode sequences as generating functions, manipulate them algebraically, use them to count selections with restrictions, and use them to solve recurrences.
    • Build and manipulate generating functions
      Write the generating function of a sequence, use the standard series and the extended binomial theorem, and add, multiply, shift and differentiate generating functions.
    • Count selections with generating functions
      Model selections and distributions with restrictions as products of generating functions, read the answer as a coefficient, and prove counting identities.
    • Solve recurrences with generating functions
      Turn a recurrence into an equation for its generating function, solve that equation, and recover a closed form with partial fractions.
  5. Count the elements of a union of overlapping sets, and use inclusion–exclusion to count bounded solutions, primes, onto functions and derangements.
    • Apply inclusion–exclusion to overlapping sets
      State and use inclusion–exclusion for two, three and n sets, explain why it counts each element once, and use its complement form.
    • Solve classic problems with inclusion–exclusion
      Use inclusion–exclusion to count bounded integer solutions, primes and integers coprime to n, onto functions and derangements.

Recurrence Relations study guide

5 chapters

1

Model and solve recurrence rules

Recurrences describe a large object or a later stage through smaller ones. The starting values and index range are part of the model, just as much as the rule itself. You will compute terms, turn repeated substitution into a closed form, and justify that formula by induction. Then you will build rules from strings, tilings, line arrangements and parenthesizations by identifying what can be removed from an object without losing its structure.

1.1 From earlier terms to a formula

A recurrence relation describes a term using earlier terms. Initial conditions start the sequence, and the index range tells you when the rule takes over. For example, an=an−1+3 for n≥1 with a0=2 gives 2,5,8,11,14,…. Here the starting index is 0; the first application of the rule produces the term at index 1.

Read and check the rule

A recurrence using the previous two terms needs two starting values. For an=2an−1−an−2, knowing only a0 leaves a1 undetermined. Once both are given, compute forward in order, keeping the earlier values available.

A proposed formula must satisfy the recurrence and the initial conditions. The formula an=3n satisfies this rule because 2⋅3(n−1)−3(n−2)=3n. A constant sequence also satisfies it. Initial values select one sequence from this family. By contrast, substituting an=2n gives 2n−2n−2 on the right, so it fails the recurrence even if a few starting values seem promising.

A closed form gives a term directly from its index. Adding 3 at each of the first n steps gives an=2+3n. For a geometric recurrence an=ran−1, each step supplies one more factor of r, so an=a0rn. A population starting at 1000 and growing by 5% per hour has Pn=1000(1.05)n; after 30 hours this is about 4322. The growth factor is 1.05, because the old population remains as well as the 5% increase.

Initial indices also affect a geometric closed form. If b1=5 and bn=2bn−1 for n≥2, reaching index n takes n−1 updates from the known value. Thus bn=5⋅2n−1, not 5⋅2n. Count the updates from the stated starting index before choosing the exponent.

Unroll a recurrence

In the Tower of Hanoi, move the top n−1 disks to the spare peg, move the largest disk, then place the smaller stack on it. With one disk requiring one move, the count satisfies Hn=2Hn−1+1 for n≥2 and H1=1. A larger disk may never rest on a smaller disk. Before the largest disk's first move the smaller stack must be on the spare peg; after its last move the smaller stack must be rebuilt on top. These two smaller tasks also give the lower bound that makes the plan optimal.

Repeated substitution, called iteration, gives

Hn=22Hn−2+2+1=23Hn−3+4+2+1.

After n−1 substitutions, Hn=2n−1H1+2n−2+⋯+1. This geometric sum is 2n−1. Thus 3 disks require 7 moves, while 64 require 264−1=18,446,744,073,709,551,615 moves.

Prove the pattern

Matching early terms suggests a formula; induction establishes it for every allowed index. The base case is H1=1=21−1. Assume Hn−1=2n−1−1. Substitution gives Hn=2(2n−1−1)+1=2n−1, completing the step. Keep the base case aligned with the recurrence's range: a rule beginning at n=2 cannot be used to create the missing starting value at n=1.

Key Takeaways

  • Initial values and the recurrence range determine where computation begins.
  • A closed form must satisfy both the recurrence and its initial conditions.
  • Iteration exposes sums or products; induction proves the resulting formula.
  • The optimal Hanoi count is Hn=2n−1.

1.2 Count objects by their final choice

To build a counting recurrence, define exactly what an counts. Split the objects of size n into cases that cover every object without overlap. Removing a final piece should leave a smaller object of the same kind. Count the smallest cases separately before trusting the rule.

Strings and tilings

Let an count bit strings of length n with no consecutive 0s. Strings ending in 1 come from any valid string of length n−1. For length at least 2, strings ending in 0 must end in “10”; removing that suffix leaves any valid string of length n−2. Thus an=an−1+an−2 for n≥3. The initial counts are a1=2 and a2=3, from “01”, “10” and “11”. The next counts are 5, 8 and 13.

For a 2×n board tiled with dominoes, inspect the left end. One vertical domino leaves width n−1; two horizontal dominoes leave width n−2. Hence tn=tn−1+tn−2 for n≥2, with t0=t1=1. The empty board has one tiling: using no dominoes. This gives t2=2 and t5=8. Ordered climbs using steps of size 1 or 2 have the same final-step split.

The Fibonacci numbers satisfy f0=0, f1=1 and fn=fn−1+fn−2. The tiling count is tn=fn+1, while the bit-string count is an=fn+2. A shared recurrence does not force identical sequences: compare the initial values and index shifts.

Use a complement inside a case

Let an count strings of n decimal digits with an even number of 0s, allowing leading zeros. A final nonzero digit gives 9an−1 strings. A final 0 needs a prefix with an odd number of 0s. Of the 10n−1 prefixes, exactly 10n−1−an−1 have that property. Therefore an=8an−1+10n−1 for n≥1, with a0=1. It gives a1=9 and a2=82. Directly, only the 18 two-digit strings with exactly one 0 are excluded from 100.

Add regions or combine two groups

For n lines with no parallels and no triple intersection, the new line meets the previous n−1 lines at distinct points. These cut it into n pieces, each adding one region. Thus Ln=Ln−1+n, L0=1, so Ln=1+n(n+1)/2. The first counts are 1, 2, 4, 7 and 11. The position conditions ensure every new piece adds a region.

For full parenthesizations of n+1 factors, the final multiplication splits the expression into two groups. If the left side contains k+1 factors, there are CkCn−1−k choices for the two sides. Summing over the possible split positions gives Cn=∑k=0n−1CkCn−1−k, C0=1. For four factors, the final split can put one, two or three factors on the left. These cases contribute C0C2=2, C1C1=1 and C2C0=2, giving C3=5. A fixed split permits independent choices on each side; different split positions are then added. The Catalan numbers begin 1,1,2,5,14,42 and have closed form Cn=(2nn)/(n+1). Here the product of earlier terms makes the recurrence nonlinear.

Key Takeaways

  • Define the objects, split them into disjoint complete cases, and count the smallest cases directly.
  • The empty object often has count 1.
  • Identical recurrence rules can produce shifted sequences with different initial values.
  • A complement can count prefixes that have the opposite property.
  • Catalan recurrences multiply counts for independently chosen left and right groups.
2

Solve constant-coefficient recurrences

Linear recurrences with constant coefficients turn sequence problems into polynomial equations. The roots determine the building blocks of a solution, while the initial values determine their coefficients. Distinct roots, repeated roots and added terms each need a different solution form. The worked calculations show how to select that form, fit its constants, and check a later term against the original recurrence.

2.1 Use distinct characteristic roots

A linear homogeneous recurrence with constant coefficients has the form an=c1an−1+⋯+ckan−k, with ck≠0. “Linear” means earlier terms appear to the first power and are not multiplied together. “Homogeneous” means there is no added term depending only on n. The coefficients stay fixed, and the degree k is the largest lag.

RuleClassification
an=an−5Linear homogeneous, constant coefficients, degree 5; the largest lag determines the degree.
an=nan−1Linear homogeneous, but the coefficient changes with the index.
an=an−1+an−22Nonlinear, because an earlier term is squared.
an=2an−1+1Linear with constant coefficients, but nonhomogeneous because of the added 1.
Turn the rule into a polynomial

Try an=rn. Divide the substituted equation by rn−k to get the characteristic equation

rk−c1rk−1−⋯−ck=0.

The nonzero last coefficient ensures 0 is not a root. For an=5an−1−6an−2, moving the terms to the left gives r2−5r+6=0, with roots 2 and 3. Track the signs when moving terms; the minus sign on the earlier sequence term becomes a plus in this polynomial.

If the degree-k equation has k distinct roots, every solution is an=α1r1n+⋯+αkrkn. A constant multiple or sum of solutions still satisfies the homogeneous recurrence. The k initial values determine the k constants.

The linearity explains why root solutions can be combined. If un and vn each satisfy the homogeneous rule, set bn=Aun+Bvn. Substituting gives ∑i=1kcibn−i=A∑i=1kciun−i+B∑i=1kcivn−i=Aun+Bvn=bn. Fixed coefficients let the constants pass through the sum, so the combined sequence also satisfies the rule.

Fit the initial conditions

Solve an=an−1+2an−2 for n≥2, with a0=2 and a1=7. The equation r2−r−2=(r−2)(r+1)=0 gives an=A2n+B(−1)n. The initial values yield A+B=2 and 2A−B=7. Adding gives 3A=9, so A=3 and B=−1. Therefore an=3⋅2n−(−1)n. At index 2, the recurrence gives 7+2⋅2=11 and the formula gives 12−1=11.

Higher degree uses the same steps. For an=6an−1−11an−2+6an−3, the polynomial factors as (r−1)(r−2)(r−3). From a0=2, a1=5, a2=15, solve A+B+C=2, A+2B+3C=5 and A+4B+9C=15. Subtracting successive equations gives B+2C=3 and 2B+6C=10, so C=2, B=−1 and A=1. The result is an=1−2n+2⋅3n. For a monic integer polynomial, integer roots must divide its constant term. In this cubic, test ±1,±2,±3,±6. Substituting 1 gives 1−6+11−6=0, so divide by r−1 to obtain r2−5r+6. Factoring that quadratic supplies the other two roots. Finding one root lowers the remaining factoring problem by one degree.

Irrational and complex roots

Fibonacci's polynomial r2−r−1 has roots ϕ=(1+5)/2 and ψ=(1−5)/2. With f0=0 and f1=1, the constants give fn=(ϕn−ψn)/5. Indeed, f0=0 gives A+B=0, so the family becomes A(ϕn−ψn). Then f1=1 gives A(ϕ−ψ)=A5=1, fixing A=1/5. The irrational terms combine to give integers. Since ∣ψ∣<1, its contribution shrinks as the index grows.

Complex roots work too. For an=−an−2, the roots are i and −i. Initial values a0=1 and a1=0 give an=(in+(−i)n)/2, the real period-4 sequence 1,0,−1,0,…. Use the actual starting indices when fitting constants; two initial values labeled 1 and 2 must be substituted at those indices.

Key Takeaways

  • Check linearity, homogeneity, constant coefficients and degree before using characteristic roots.
  • With distinct roots, use one constant times rn for each root.
  • Fit constants at the given initial indices and check one later term.
  • Characteristic roots can be irrational or complex even when sequence values are real integers.

2.2 Include powers of the index for repeated roots

A repeated characteristic root needs more than one exponential term. Writing A3n+B3n only gives (A+B)3n, so it contains one effective constant. A second-order recurrence generally needs two constants to meet its two initial values.

A double root

When the characteristic polynomial is (r−r0)2, the general solution is an=(A+Bn)r0n. The independent building blocks are r0n and nr0n. To see why the second works, the repeated-root polynomial has coefficients c1=2r0 and c2=−r02. Substitution gives

2r0(n−1)r0n−1−r02(n−2)r0n−2=r0n(2(n−1)−(n−2))=nr0n.

This verifies the extra building block directly; the factor n supplies the additional freedom.

For an=6an−1−9an−2, n≥2, a0=1 and a1=6, the polynomial is r2−6r+9=(r−3)2. Write an=(A+Bn)3n. At index 0, A=1. At index 1, 3(A+B)=6, so B=1. The closed form is an=(n+1)3n. The next term checks: 6⋅6−9⋅1=27, and 3⋅32=27.

Trying only A3n would force A=1 from the first value but A=2 from the second. That conflict concerns the incomplete solution form, not the consistency of the recurrence. Include the missing n3n term before fitting the data.

Higher multiplicities and mixed roots

A root r of multiplicity m contributes

(A0+A1n+⋯+Am−1nm−1)rn.

The polynomial stops at degree m−1. Sum these contributions over the distinct roots. Their multiplicities add to the recurrence degree, so the solution has exactly that many independent constants.

For roots 2 of multiplicity 3, −1 of multiplicity 1, and 5 of multiplicity 2, use

an=(A+Bn+Cn2)2n+D(−1)n+(E+Fn)5n.

There are six constants and six initial values. The simple root −1 needs no index factor; the triple root 2 needs three powers, from n0 through n2. Repetition means multiplicity in the factored polynomial, not that a sequence happens to repeat its values.

The solving order is unchanged: determine the degree, factor the characteristic polynomial, record every multiplicity, write all building blocks, and then substitute the initial values. A later-term check is especially useful when the terms have similar forms. This homogeneous solution also provides the freely adjustable part when an added forcing term is present.

Key Takeaways

  • A root of multiplicity m contributes rn,nrn,…,nm−1rn.
  • Two copies of the same exponential collapse into one effective constant.
  • The number of independent constants equals the total root multiplicity.

2.3 Add a particular solution before fitting constants

An added term changes the problem: an=c1an−1+⋯+ckan−k+F(n) is nonhomogeneous when F(n) is not identically zero. Dropping that term gives the associated homogeneous recurrence. Its solution supplies the adjustable constants; one particular solution supplies the response to the added term.

Separate the two parts

Every solution has the form an=hn+pn, where hn is the general homogeneous solution and pn is any one particular solution. Subtracting two nonhomogeneous solutions cancels F(n), leaving a homogeneous solution. This explains why one particular solution is enough.

Find hn, choose and solve for pn, add them, and only then impose the initial conditions. Fitting the homogeneous part first usually fixes the wrong constants, because the particular part also contributes to the starting values.

Choose a trial form

If F(n)=Pt(n)sn, with Pt a degree-t polynomial, try Qt(n)sn with every coefficient of Qt unknown. If s is a characteristic root of multiplicity m, multiply the whole trial by nm. A pure polynomial uses s=1; check whether 1 is a root before selecting its trial. A term such as log⁡n does not have this form.

For an=3an−1+2n, n≥2, a1=3, the homogeneous part is A3n. Since 1 is not a root, set pn=cn+d. Substitution gives cn+d=3(c(n−1)+d)+2n. Matching the coefficients of n gives c=3c+2, so c=−1. Constants give d=−3c+3d, so d=−3/2. Now an=A3n−n−3/2. From 3A−1−3/2=3, obtain A=11/6. The formula gives a2=13, agreeing with 3⋅3+4.

For an=5an−1−6an−2+7n, roots 2 and 3 do not include 7. Try pn=C7n. Divide the substituted equation by 7n−2 to obtain 49C=35C−6C+49, hence C=49/20. The full family is A2n+B3n+(49/20)7n.

Resolve a root collision

For an=2an−1+2n, n≥1, a0=1, the trial C2n is already homogeneous and cancels out of the left-minus-right calculation. Use pn=Cn2n. Dividing the substituted equation by 2n gives Cn=C(n−1)+1, hence C=1. Adding A2n and applying a0=1 yields an=(n+1)2n.

A double collision needs two index powers. For an=4an−1−4an−2+2n, the polynomial (r−2)2 gives trial pn=Cn2 2n. Move the earlier terms left and divide by 2n to get C(n2−2(n−1)2+(n−2)2)=1. The expression in parentheses is 2, so C=1/2. The full family is (A+Bn+n2/2)2n. A trial with only n2n would still be homogeneous and cancel completely.

Likewise an=an−1+n has root 1. Use pn=n(cn+d); coefficient matching gives c=d=1/2. With a0=0, the answer is n(n+1)/2. For Hanoi, the constant trial satisfies C=2C+1, so C=−1; adding the homogeneous part recovers 2n−1. An impossible coefficient equation is a reason to check for a root collision before abandoning the method.

Key Takeaways

  • Every solution is a particular solution plus the general homogeneous solution.
  • For polynomial times sn forcing, use the same polynomial degree in the trial.
  • If s has characteristic multiplicity m, multiply the trial by nm.
  • Fit the initial conditions to the full sum, including the particular solution.
  • An index-dependent coefficient of an earlier term is not a forcing term.
3

Count work in recursive algorithms

Divide-and-conquer recurrences track algorithms that solve smaller copies of a task. A count of recursive calls, a size reduction and the work outside those calls together define the model. You will sum the work across levels to find exact costs at powers of the split factor, then use the master theorem to identify growth bounds. Keeping exact counts separate from bounds matters especially in comparison-counting examples.

3.1 Unroll equal-size recursive tasks

A divide-and-conquer algorithm solves smaller versions of the same task and combines their answers. If it solves a subproblems of size n/b and uses extra work g(n), its recurrence is T(n)=aT(n/b)+g(n). Count the subproblems actually solved, and state the base size and its cost.

Read the algorithm into the rule

Binary search divides a sorted list into halves but continues in only one half. A model using two comparisons per stage is T(n)=T(n/2)+2: here a=1. Merge sort solves both halves. Merging n items takes at most n−1 comparisons, so its worst-case count is M(n)=2M(n/2)+n−1 with M(1)=0.

Finding both the maximum and minimum can use two half-size tasks, then compare the two maxima and the two minima. Its rule is T(n)=2T(n/2)+2 with T(2)=1. The terminal size matters: a two-item list needs one comparison to find both extremes. For powers of 2 this yields T(n)=3n/2−2, including T(8)=10. To see the formula, stop the recursion at size 2: there are n/2 terminal pairs, each costing one comparison. The internal levels contain 1+2+⋯+n/4=n/2−1 tasks in all, each costing two comparisons. Their total is n/2+2(n/2−1)=3n/2−2. Finding the maximum first and then the minimum among the remaining entries instead uses 2n−3=13 comparisons at size 8.

Karatsuba multiplication replaces four half-size products with three, plus linear extra work: T(n)=3T(n/2)+Cn. Strassen's matrix multiplication uses seven half-size products and quadratic extra work, modeled here as T(n)=7T(n/2)+(15/4)n2. The number of recursive calls and the cost outside them are different parts of each rule.

Keep each level's full cost

Assume n=bk and base size 1. After one substitution, T(n)=a2T(n/b2)+ag(n/b)+g(n). After k substitutions,

T(n)=akT(1)+∑j=0k−1ajg(n/bj).

There are aj calls at level j, which explains the multiplier in the sum. The leaves contribute akT(1). For constant extra cost c and a=1, this is T(1)+clog⁡bn. For a>1, sum the geometric series to get T(n)=(T(1)+c/(a−1))nlog⁡ba−c/(a−1).

For merge sort, level j costs 2j(n/2j−1)=n−2j. Summing for 0≤j<k gives kn−(2k−1). Thus M(n)=nlog⁡2n−n+1, and M(8)=24−8+1=17. Replacing n−1 by n gives the simpler bound nlog⁡2n with the same zero base cost, not the exact comparison count.

Change the size variable

Set Bk=M(2k). Then Bk=2Bk−1+2k−1 and B0=0, a constant-coefficient recurrence in k. Its solution Bk=k2k−2k+1 becomes the same exact formula after substituting k=log⁡2n. Exact formulas here use powers of the split factor. Other sizes need floors or ceilings for integer subproblem sizes; an increasing cost allows growth bounds to extend between neighboring powers.

Key Takeaways

  • Count recursive calls actually solved: binary search has one, merge sort has two.
  • Unrolling includes both level costs and the terminal calls.
  • For powers of 2, merge sort uses nlog⁡2n−n+1 comparisons in the worst case.
  • A change of variable n=bk turns shrinking sizes into successive indices.
  • The terminal size and its cost affect an exact formula.

3.2 Compare the work across recursion levels

The master theorem gives growth bounds without evaluating every level of a divide-and-conquer recurrence. Big-O means an eventual upper bound up to a constant factor: T(n)=O(h(n)) if ∣T(n)∣≤C∣h(n)∣ for all sufficiently large n and some fixed C. It does not give an exact count.

State and select the case

Use the polynomial-cost form for an increasing function satisfying T(n)=aT(n/b)+cnd at powers n=bk, with a≥1, integer b>1, c>0 and d≥0. Compare a with bd:

ComparisonGrowth bound
a<bdO(nd)
a=bdO(ndlog⁡n)
a>bdO(nlog⁡ba)

The constant c changes the amount of work without changing the case. A constant extra cost has d=0, so the comparison uses b0=1. The logarithm base does not affect a big-O bound because changing its base multiplies it by a constant.

Explain the three outcomes

At level j, there are aj tasks of size n/bj. Their extra work totals cnd(a/bd)j. If the ratio is below 1, the costs shrink and a geometric sum is bounded by a constant times the top cost. If the ratio is 1, every level costs cnd and there are log⁡bn such levels. If the ratio exceeds 1, lower levels dominate; the number of leaves is alog⁡bn=nlog⁡ba.

For T(n)=2T(n/2)+n2, compare 2 with 22=4 to get O(n2). With four calls the bound becomes O(n2log⁡n). With eight calls it becomes O(nlog⁡28)=O(n3). Comparing the call count with b alone would miss this distinction.

For a ratio q=a/bd<1, the internal-level sum is at most cnd/(1−q): the finite geometric sum is bounded by the corresponding infinite sum. The leaf count nlog⁡ba has a smaller exponent than nd, so it fits the same upper bound. When q>1, the sum is (qk−1)/(q−1) for k=log⁡bn. Multiplying its largest scale by nd gives ndqk=ak=nlog⁡ba, matching the leaf scale. These sums explain why a fixed number of large bottom levels controls the growing-ratio case.

Apply and interpret the result

Merge sort's bound T(n)=2T(n/2)+n has equal level costs and gives O(nlog⁡n). Binary search's model T(n)=T(n/2)+2 uses a=1=b0 and gives O(log⁡n). The maximum-and-minimum rule T(n)=2T(n/2)+2 instead has 2>1, giving O(n).

Karatsuba's three half-size products plus linear work give O(nlog⁡23), about O(n1.585). Strassen's seven half-size products plus quadratic work give O(nlog⁡27), about O(n2.807). The exponent uses the split factor as logarithm base; reversing it changes the answer.

Check the form before applying it

This polynomial-cost version does not cover 2T(n/2)+nlog⁡n, unequal splits such as T(n/3)+T(2n/3)+n, or shrinking by subtraction as in T(n−1)+n. The first has a nonpolynomial extra cost, the second has unequal task sizes, and the third does not divide size by a fixed factor. Unrolling can still work when this theorem does not. In the equality case, it also gives the exact power-of-b formula T(n)=T(1)nd+cndlog⁡bn.

Key Takeaways

  • For polynomial extra cost, compare a with bd.
  • Equal level costs produce the logarithmic factor.
  • Growing level costs produce the exponent log⁡ba.
  • Check the theorem conditions before selecting a case.
  • Big-O describes a growth bound; exact costs require the base condition and unrolling.
  • The coefficient of the extra cost does not change the case.
4

Use generating functions

A generating function places an entire sequence inside one algebraic expression. Coefficients carry the counts, and exponents keep track of size. The same algebra can combine independent choices, enforce restrictions or gather a recurrence into one equation. You will learn standard series, use products to model selections, and recover closed forms through shifts and partial fractions, with initial values entering through missing terms.

4.1 Store a sequence in a power series

The ordinary generating function of a0,a1,… is G(x)=∑n≥0anxn. The exponent records the index, while its coefficient records the term. Write [xn]G(x)=an for coefficient extraction. Here x is a placeholder in a formal power series; the coefficient calculations do not require assigning it a numerical value.

Recognize useful series

The geometric identity gives 1/(1−x)=1+x+x2+⋯ and 1/(1−ax)=∑n≥0anxn. Replacing a by −1 gives 1/(1+x)=1−x+x2−⋯. Replacing x by xr gives 1/(1−xr)=1+xr+x2r+⋯, with zero coefficients at other exponents. A finite string of six 1s has polynomial 1+x+⋯+x5=(1−x6)/(1−x).

As numerical functions, the geometric series converge for ∣x∣<1, or ∣ax∣<1 in the scaled case. Formal algebra keeps these coefficient identities separate from questions about numerical convergence. Evaluating G(1/2) gives a weighted sum of terms; it does not select one coefficient.

Add, multiply and shift

Adding two generating functions adds coefficients at matching powers. Multiplying uses convolution:

[xn](A(x)B(x))=∑j=0najbn−j.

For example, (1+x+x2)(1+x)=1+2x+2x2+x3. The coefficient 2 at x2 comes from x2⋅1 and x⋅x. It is not obtained by multiplying just the two coefficients already at index 2.

Multiplication by xm shifts every term m places right and inserts initial zeros. Thus x/(1−x) represents 0,1,1,…. Substitution G(ax) instead multiplies the coefficient at index n by an. Differentiation gives G′(x)=∑n≥0(n+1)an+1xn; multiplying by x restores the indices, so xG′(x)=∑n≥0nanxn. For G(x)=1/(1−x), differentiation gives G′(x)=1/(1−x)2, whose coefficients are 1,2,3,…. Multiplying by x shifts this sequence once, so x/(1−x)2 represents 0,1,2,3,…. For example, its coefficient at x4 is 4; the derivative alone has coefficient 5 there.

Extend the binomial theorem

For real u and integer k≥0, define (u0)=1 and (uk)=u(u−1)⋯(u−k+1)/k!. This falling-product definition works when the upper entry is negative. For instance, (−23)=(−2)(−3)(−4)/6=−4. The extended theorem is (1+x)u=∑k≥0(uk)xk, numerically valid for ∣x∣<1.

For positive integer q, (−qk)=(−1)k(q+k−1k). Substituting −x cancels the signs and yields

1(1−x)q=∑k≥0(q+k−1k)xk.

With q=2 the coefficient is k+1. With q=3, the coefficient at index 10 is (1210)=66. Keep index and coefficient distinct: the exponent 10 identifies which entry is requested, while 66 is that entry's value.

Key Takeaways

  • An ordinary generating function stores sequence terms as coefficients.
  • Products use convolution; multiplication by xm shifts indices.
  • In xG′(x), the coefficient at index n is nan.
  • The coefficient of xk in (1−x)−q is (q+k−1k) for positive integer q.
  • Negative upper entries in binomial coefficients use the falling-product definition.

4.2 Turn allowed choices into factors

For an unordered selection from distinguishable kinds, make one generating-function factor per kind. Its exponents are the allowed contributions to the total. Multiplication chooses one term from every factor, adds the exponents, and records how many choices produce each total. Coefficients count the choices; the powers record their size.

Translate restrictions literally

An unlimited number of one kind gives 1+x+x2+⋯=1/(1−x). At least one gives x/(1−x); at most one gives 1+x. At most m gives (1−xm+1)/(1−x). An even number gives 1/(1−x2). Include the constant 1 exactly when choosing zero is allowed.

For solutions of e1+e2+e3=17 with 2≤e1≤5, 3≤e2≤6 and 4≤e3≤7, the product is

(x2+x3+x4+x5)(x3+x4+x5+x6)(x4+x5+x6+x7).

Factor out the minimum contributions, whose sum is 9. The product becomes x9(1+x+x2+x3)3=x9(1−x4)3/(1−x)3. The target is now [x8](1−x4)3/(1−x)3. Expand only the short numerator: (1−x4)3=1−3x4+3x8−x12. Using the standard coefficients of (1−x)−3 gives (102)−3(62)+3(22)=45−45+3=3. The term with x12 cannot contribute to x8 because the denominator series has no negative powers.

A direct check uses the maximum total 18: total 17 is one below it, giving (4,6,7), (5,5,7) and (5,6,6). The algebra handles the upper bounds through the numerator while the denominator counts unrestricted remaining contributions.

Remove minimums before expanding

Sharing 8 identical items among three people, with each receiving between 2 and 4, gives (x2+x3+x4)3=x6(1+x+x2)3. Extracting x8 now means extracting x2 from the remaining cube. Choose a single exponent 2 in three ways, or two exponents 1 in three ways, giving 6. The removed minimums change the target exponent from 8 to 2.

With four fruit kinds and no limits, selecting six pieces gives [x6](1−x)−4=(96)=84. If the kinds have different values, put those values in the exponents: unlimited coins worth 1, 2 and 5 units give 1/((1−x)(1−x2)(1−x5)). To make total 10, use zero 5-unit coins in six ways, one in three ways, or two in one way, for 10 selections.

Decide whether order matters

A factor per kind counts how many of each kind, not their arrangement. For parts of size 1 or 2 totaling 4, the product 1/((1−x)(1−x2)) counts three unordered selections. Ordered lists include “112”, “121” and “211” separately. For a list of length j, use (x+x2)j; summing over j≥0 gives 1/(1−x−x2), whose x4 coefficient is 5. The difference is in the combinatorial model, not in whether the generating function is ordinary.

The sum over list lengths is valid as a formal series: each part has positive size, so only lengths j≤r can contribute to a target xr. Even though the series has infinitely many list lengths, a particular coefficient uses only finitely many of them. A zero-size part would change this reasoning by allowing arbitrarily many positions without increasing the total; it is not present in this model.

Compare coefficients to prove an identity

From (1+x)2n=(1+x)n(1+x)n, compare coefficients of xn. On the left it is (2nn). On the right convolution gives ∑k=0n(nk)(nn−k)=∑k=0n(nk)2. For n=4 the sum is 1+16+36+16+1=70. Equality of the series forces equality of the coefficients at every index.

Key Takeaways

  • Use one factor per kind, with exponents equal to its allowed contributions.
  • Minimum amounts shift the target coefficient; maximum amounts make factors finite.
  • Weighted kinds contribute powers matching their sizes or values.
  • One factor per kind counts unordered selections; ordered lists need a different model.
  • Comparing coefficients of equal series proves counting identities.
  • The constant term represents choosing none of a kind.

4.3 Convert a recurrence into one algebraic equation

A generating function collects every recurrence equation into one series equation. Initial values enter through the terms missing at the beginning of each sum. After solving for the series, standard expansions recover the sequence.

Match the summation range

Let G(x)=∑n≥0anxn. For an=3an−1, n≥1, a0=2, multiply by xn and sum over n≥1. The left side is G(x)−2 and the right is 3xG(x). Thus G(x)=2/(1−3x) and an=2⋅3n.

For a second-order recurrence beginning at n=2, the left sum is G(x)−a0−a1x. The first shifted sum is x(G(x)−a0), while the second is x2G(x). To derive the first shift, put m=n−1: ∑n≥2an−1xn=x∑m≥1amxm=x(G(x)−a0). For the second, m=n−2 starts at 0, giving x2∑m≥0amxm=x2G(x). Writing the changed lower limit before simplifying keeps these corrections visible.

Solve and split into standard fractions

Take an=5an−1−6an−2, n≥2, with a0=1 and a1=4. Summing gives

G(x)−1−4x=5x(G(x)−1)−6x2G(x).

Collecting the terms containing G yields G(x)(1−5x+6x2)=1−x, so G(x)=(1−x)/((1−2x)(1−3x)).

For partial fractions, write G(x)=A/(1−2x)+B/(1−3x). Clearing denominators gives 1−x=A(1−3x)+B(1−2x). At x=1/2, 1/2=−A/2, so A=−1; at x=1/3, 2/3=B/3, so B=2. Expand each geometric series to obtain an=−2n+2⋅3n. The recurrence gives a2=5⋅4−6=14, agreeing with −4+18.

Read roots in the denominator

The polynomial 1−5x+6x2 reverses the coefficients of r2−5r+6. Its factors 1−2x and 1−3x correspond to roots 2 and 3. A repeated factor (1−rx)2 has expansion ∑n≥0(n+1)rnxn, so its coefficients contain a linear factor in the index. This is the generating-function form of repeated characteristic roots. For Fibonacci, f0=0 and f1=1 give F−x=xF+x2F after summing from 2. Thus F(x)=x/(1−x−x2). Its numerator has no constant term because the sequence begins at zero; the coefficient of x is one.

Include an added term

For decimal strings with an even number of 0s, an=8an−1+10n−1 and a0=1. Summing the extra term gives ∑n≥110n−1xn=x/(1−10x). Hence G(x)−1=8xG(x)+x/(1−10x). Solving and decomposing produces

G(x)=1−9x(1−8x)(1−10x)=12(11−8x+11−10x).

Therefore an=(8n+10n)/2. This method incorporates the forcing without guessing a particular solution. Before expanding any rational function, check its constant term against a0; a mismatch often reveals a missing initial-term subtraction.

Key Takeaways

  • Sum only over the indices where the recurrence holds.
  • Shifted sums require the correct missing initial terms to be subtracted.
  • Partial fractions convert rational functions into standard series.
  • Factors 1−rx correspond to characteristic roots r.
  • The generating-function equation can include forcing and initial values together.
5

Count overlapping restrictions

Overlapping groups need more care than simply adding their sizes. Inclusion–exclusion corrects repeated membership by alternating counts of intersections. You will see why every included object ends up counted once, then choose useful unwanted properties for bounded distributions, divisibility, onto functions and permutations. Each application depends on describing what an intersection allows the remaining objects to do.

5.1 Correct overlap one intersection at a time

Adding set sizes overcounts objects that belong to more than one set. Inclusion–exclusion corrects each overlap, with alternating signs as the number of intersected sets increases. The union counts membership in at least one set; a complement counts membership in none.

Two and three sets

For finite sets, ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣. An element in both sets was counted twice, so subtract it once. Disjoint sets have empty intersection and the expression reduces to the sum rule.

Among integers from 1 through 1000, there are ⌊1000/7⌋=142 multiples of 7 and ⌊1000/11⌋=90 multiples of 11. The 12 multiples of 77 occur in both groups. Thus 142+90−12=220 integers are divisible by 7 or 11.

For three sets, use

∣A∪B∪C∣=∣A∣+∣B∣+∣C∣−∣A∩B∣−∣A∩C∣−∣B∩C∣+∣A∩B∩C∣.

An element in all three sets is added three times, then subtracted in all three pairs. Add it back once. Pair intersections include those triple members; they do not mean membership in exactly two sets.

For divisibility by 3, 5 or 7 among 1 through 1000, the single counts are 333, 200 and 142. The pair counts are 66, 47 and 28, using multiples of 15, 21 and 35. The triple count is 9. The union has 333+200+142−66−47−28+9=543 members. Therefore 1000−543=457 are divisible by none of these three numbers.

Use least common multiples

A number divisible by both 4 and 6 is a multiple of 12, their least common multiple. Using the product 24 misses common multiples such as 12 and 36. For positive integers 1 through N, a divisibility intersection by numbers d1,…,dj has size ⌊N/lcm⁡(d1,…,dj)⌋. Products work for distinct primes because those primes have no shared factors.

Extend and justify the pattern

For m sets, sum every nonempty intersection. An intersection of k sets has sign (−1)k+1: singles positive, pairs negative, triples positive. There are 2m−1 intersection terms. If an element belongs to exactly r≥1 sets, its net count is

(r1)−(r2)+⋯+(−1)r+1(rr)=1.

The binomial identity ∑k=0r(−1)k(rk)=(1−1)r=0 proves this after the index-0 term is moved across. Elements outside all sets contribute 0.

To count objects with none of several unwanted properties, start with the universe size and subtract the union. Equivalently, begin with N, subtract single-property counts, add pair-property counts, and continue alternating. Label what each intersection means before doing arithmetic; a correct calculation of a union still answers the wrong question if “none” was requested.

Key Takeaways

  • Add single sets, subtract pair intersections, and add triple intersections.
  • Pair intersections include elements in further sets.
  • Divisibility intersections use least common multiples.
  • Count “none” by subtracting the union from the universe.
  • The alternating binomial sum makes each included element count exactly once.

5.2 Choose the unwanted properties

Inclusion–exclusion becomes a modeling tool when each set represents a specific unwanted property. Begin with an easy total, count intersections of violations, and alternate the corrections. The main work is finding the size of each intersection.

Bounded integer solutions

Count nonnegative solutions of x1+x2+x3=11 with upper bounds 3, 4 and 6. Without upper bounds there are (132)=78. Violations begin at x1=4, x2=5 and x3=7. Shifting a violating variable down by its threshold leaves totals 7, 6 or 4, so the single violation counts are (92)=36, (82)=28 and (62)=15.

For simultaneous violations, subtract both thresholds from the total. Thresholds 4 and 5 leave 2, giving (42)=6; thresholds 4 and 7 leave 0, giving (22)=1. Thresholds 5 and 7 exceed 11, so that intersection is empty. The triple is empty too. The count is 78−(36+28+15)+(6+1)=6. A violation starts one above an allowed upper bound, and a negative remaining total contributes zero.

Sieve and coprime counts

Every composite integer at most 100 has a prime factor at most 100=10. Exclude multiples of 2, 3, 5 and 7 from integers 2 through 100. The single counts are 50, 33, 20 and 14, totaling 117. Pair intersections use divisors 6, 10, 14, 15, 21 and 35; their counts are 16, 10, 7, 6, 4 and 2, totaling 45. The triple divisors 30, 42, 70 and 105 give counts 3, 2, 1 and 0. The fourfold divisor 210 contributes zero. Inclusion–exclusion therefore gives 99−117+45−6=21 survivors. These are primes larger than 7; restore 2, 3, 5 and 7 themselves to obtain 25 primes up to 100. Starting from 1 through 100 would also leave 1, which is not prime.

Integers coprime to N share no prime factor with it. For 60=22⋅3⋅5, exclude multiples of 2, 3 and 5 from 1 through 60. The count is 60−(30+20+12)+(10+6+4)−2=16. Factoring the inclusion–exclusion expression gives Euler's function ϕ(N)=N∏p∣N(1−1/p), with one factor per distinct prime divisor.

Onto functions

For functions from an m-element domain onto an n-element codomain, let the bad property be “this codomain element is missed.” Missing a specified set of i outputs leaves (n−i)m functions, and there are (ni) such output sets. For positive m,n, the count is ∑i=0n(−1)i(ni)(n−i)m. From 6 elements onto 3 it is 729−3⋅64+3=540. Subtracting only the single-output omissions would overcorrect functions missing multiple outputs.

Derangements

A derangement is a permutation with no fixed element. Fixing a specified set of k elements leaves (n−k)! permutations. Inclusion–exclusion gives Dn=∑k=0n(−1)k(nk)(n−k)!=n!∑k=0n(−1)k/k!. For 4 elements, D4=24−24+12−4+1=9. Fixing some elements permits additional fixed elements among the rest; an intersection is not an “exactly” count.

The numbers also satisfy Dn=(n−1)(Dn−1+Dn−2) for n≥3, with D1=0 and D2=1. Choose the destination of the last element; a swap leaves a derangement of n−2 elements, and the nonswap case corresponds to one of n−1 elements. In the nonswap case, view a permutation as arrows from each element to its assigned position. If n points to k and j points to n, deleting n replaces j→n→k by j→k. Since this is not a swap, j≠k, so the replacement creates no fixed point. It gives a derangement on the other n−1 elements. Conversely, in any such derangement, insert n into the unique arrow ending at the chosen k. These operations undo each other, justifying the Dn−1 contribution for each choice of k. The swap case contributes Dn−2 because both swapped elements are removed.

The derangement counts begin 0,1,2,9,44,265,1854. The fraction Dn/n! approaches 1/e; for n≥1, Dn is the integer nearest to n!/e.

Key Takeaways

  • For upper bound u, the bad property begins at u+1.
  • Impossible simultaneous violations contribute zero.
  • Sieving primes removes the small sieving primes themselves, which must be restored.
  • Euler’s function excludes multiples of each distinct prime divisor.
  • Onto functions exclude missed outputs; derangements exclude fixed positions.
  • Fixing k specified positions leaves (n−k)! permutations.
  • Derangements can be counted by an alternating sum or their own recurrence.

Recurrence Relations examples

5 Walkthroughs

1

Build a sequence and explain its count

12 steps
Compute a rule, uncover its closed form, then justify a counting recurrence through cases.
  1. 1
    IntroductionA later count depends on earlier ones

    A recurrence computes later terms from earlier ones. We will solve a numerical rule by repeated substitution, then build a tiling recurrence from disjoint cases. In each task, the starting values explain which sequence the rule describes.

  2. 2
    ExplanationLocate the first update

    Take an=3an−1+2 for n≥1, with a0=1. Successive updates give a1=5, a2=17 and a3=53. The known value is at index 0, so reaching index 3 requires three updates.

  3. 3
    ExampleSubstitute before simplifying

    Unroll the same rule one step at a time:

    an=3(3an−2+2)+2=32an−2+2⋅3+2.

    One more substitution gives 33an−3+2(32+3+1). After n substitutions the earlier term is the known starting value: an=3na0+2(1+3+⋯+3n−1). The added 2s have different weights because earlier additions are multiplied again at later stages.

  4. 4
    ExampleEvaluate the geometric sum

    The geometric sum is 1+3+⋯+3n−1=(3n−1)/2. Substitute this into the unrolled expression with a0=1 to get an=3n+2(3n−1)/2=2⋅3n−1. At index 3 it gives 53, matching the computed term; induction will verify every index.

  5. 5
    ChallengeComplete the induction step

    For the proposed formula an=2⋅3n−1, the base case gives a0=1. Assuming the formula at index n−1, how does the recurrence produce it at index n?

    ---reveal---

    Substitute the hypothesis: 3(2⋅3n−1−1)+2=2⋅3n−3+2=2⋅3n−1. The recurrence and base case now establish the formula for every nonnegative index.

  6. 6
    ExplanationDefine the tilings being counted

    Let tn count tilings of a length-n strip with tiles of lengths 1 and 2, with order significant. The empty strip has one tiling, so t0=1, and t1=1. At length 2 the two tilings are “1+1” and “2”.

  7. 7
    ExampleRemove the last tile

    Every nonempty tiling ends in a length-1 tile or a length-2 tile. Removing the last tile leaves a strip of length n−1 or n−2, respectively.

    In each case removal is reversible: append the specified tile to any tiling of the shorter strip. This gives exactly one original tiling for each shorter tiling, so the counts are tn−1 and tn−2. The cases neither overlap nor omit any allowed ending. Thus tn=tn−1+tn−2 for n≥2.

  8. 8
    ChallengeUse the empty tiling

    Compute the tiling counts at lengths 2, 3 and 4 from t0=t1=1. What would be lost at length 2 if the empty tiling had count 0?

    ---reveal---

    The updates give t2=1+1=2, t3=2+1=3 and t4=3+2=5. At length 3, the three tilings are “1+1+1”, “1+2” and “2+1”. If t0=0, the length-2 update would omit the single length-2 tile, whose removal leaves an empty strip. That error would then propagate to every later count.

  9. 9
    ConnectionThe same rule can start differently

    Let bn count bit strings without consecutive 0s. The endings “1” and “10” give the same recurrence as the tilings, but b1=2 and b2=3.

    Fibonacci starts with f0=0 and f1=1. Comparing initial terms gives tn=fn+1 and bn=fn+2. Shared dependence on the previous two terms identifies a family of models; it does not erase their starting values.

  10. 10
    Key InsightA split can require multiplication

    A parenthesized product ends with a multiplication of a left group and a right group. For a fixed split, choose a parenthesization of each group independently and multiply their counts. Then add across split positions.

    This gives Cn=∑k=0n−1CkCn−1−k, with C0=1. Unlike the tiling rule, it contains products of earlier terms. A recurrence built from valid cases need not be linear.

  11. 11
    ChallengeTest a claimed shared solution

    A learner claims that the tiling counts equal the Fibonacci numbers at the same index because both use the previous-two-terms rule. How can you settle the claim and identify the correct shift?

    ---reveal---

    Check initial values: t0=1 but f0=0, so same-index equality fails. The values t0=f1=1 and t1=f2=1 agree, and the shared recurrence propagates that agreement: tn=fn+1.

  12. 12
    RecapMatch the rule to the sequence

    Compute from the initial values, unroll the rule, and prove a resulting formula by induction. To build a counting rule, remove a final piece and justify a disjoint, complete split into smaller objects. Count the smallest cases directly, including the empty object.

2

Choose the right solution form

16 steps
Work through distinct roots, repeated roots and a forcing term that collides with a root.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionThe polynomial chooses the building blocks
  2. 2
    ExplanationCheck the type before solving
  3. 3
    ExampleFind the two characteristic roots
  4. 4
    ExampleUse both initial values
  5. 5
    ChallengeKeep the given starting indices
  6. 6
    ExplanationMake repeated roots independent
  7. 7
    ExampleFit a double-root solution
  8. 8
    ChallengeRead mixed multiplicities
  9. 9
    ExplanationKeep one response to the forcing
  10. 10
    ExampleFind a particular solution with no collision
  11. 11
    ExampleDetect a collision with a root
  12. 12
    ExampleSubstitute the adjusted trial
  13. 13
    ChallengeChoose the full polynomial trial
  14. 14
    TipTreat a polynomial as base one
  15. 15
    ChallengeExplain a failed initial-value fit
  16. 16
    RecapBuild the family before fitting it
3

Follow work down a recursion tree

11 steps
Build and unroll a cost recurrence, then explain the three polynomial-cost master-theorem cases.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionCount tasks and work separately
  2. 2
    ExampleWrite the two-call model
  3. 3
    ExampleSum internal work and leaves
  4. 4
    ChallengeMove the base size
  5. 5
    ConnectionReplace size by its exponent
  6. 6
    ExplanationRead the level-cost ratio
  7. 7
    ExampleEqual cost on every level
  8. 8
    ExplanationShrink or grow across levels
  9. 9
    ChallengeUse the tree to check the case
  10. 10
    TipCheck the exact theorem form
  11. 11
    RecapKeep exact costs and bounds distinct
4

Read counts from generating functions

16 steps
Use series operations, model restricted selections and solve a recurrence with its initial terms intact.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionLet coefficients carry the counts
  2. 2
    ExplanationEncode an entire sequence
  3. 3
    ExampleMultiply choices with matching total exponents
  4. 4
    Key InsightA shift changes the requested position
  5. 5
    ExplanationUse a binomial coefficient identity
  6. 6
    ChallengeCombine a shift and a standard series
  7. 7
    ExplanationBuild factors from allowed amounts
  8. 8
    ExampleExtract a count without full expansion
  9. 9
    ChallengeRemove the minimum before counting
  10. 10
    ConnectionKeep order in the model
  11. 11
    ExplanationWrite the missing initial terms
  12. 12
    ExampleCollect the rational expression
  13. 13
    ExampleSplit into standard series
  14. 14
    ChallengeTranslate a forcing term
  15. 15
    ChallengeRecover a selection sequence from its rule
  16. 16
    RecapUse the right meaning of each power
5

Remove unwanted properties without overcorrecting

14 steps
Explain alternating intersections, then count bounded solutions, onto assignments and fixed-point restrictions.

Save this lesson to follow every Walkthrough step by step.

  1. 1
    IntroductionBegin with an easy universe
  2. 2
    ExplanationTwo properties share members
  3. 3
    Key InsightTrack an element in all three sets
  4. 4
    ChallengeFinish with the complement
  5. 5
    ExplanationCount one element with many memberships
  6. 6
    ExampleTurn an upper bound into a bad property
  7. 7
    ExampleCheck whether two violations can coexist
  8. 8
    ChallengeCount an onto assignment
  9. 9
    ExplanationAvoid fixed positions
  10. 10
    ExampleSeparate specified from exactly
  11. 11
    ConnectionRemove shared prime factors
  12. 12
    TipRestore the small sieving primes
  13. 13
    ChallengeIdentify the intersection before subtracting
  14. 14
    RecapName the property before counting it

Recurrence Relations practice questions

40 Practice Questions in 4 sets

Set 1: Read recurrence rules and counting models10 Practice Questions

Question 1 of 10

How many nonnegative integer triples satisfy u+v+w=9, with u≤2 and v even?
  1. 14
  2. 15
  3. 18
  4. 12
Show answerHide answer
Answer: A
For u=0 or 1, the allowed even values of v are 0,2,4,6,8, giving five choices in each case; for u=2 they are 0,2,4,6, giving four. Each pair fixes one nonnegative value w=9−u−v, so the count is 5+5+4=14. Counting five choices in every case gives 15 but includes u=2,v=8, which would force w=−1.

Question 2 of 10

Among integers 1 through 180, how many are divisible by 6 or 10?
  1. 48
  2. 42
  3. 45
  4. 36
Show answerHide answer
Answer: B
There are ⌊180/6⌋=30 multiples of 6 and 18 multiples of 10. Their intersection consists of the 6 multiples of lcm⁡(6,10)=30, so the union has 30+18−6=42 members. Using the product 60 for the intersection subtracts only 3 and misses shared multiples.

Question 3 of 10

What is the coefficient of x5 in 1/(1+2x)?
  1. −32
  2. 32
  3. −16
  4. 10
Show answerHide answer
Answer: A
The expansion of 1/(1−(−2)x) has coefficient (−2)n at index n, giving (−2)5=−32. Using 32 loses the negative sign at an odd index.

Question 4 of 10

For an=3an−1−1 for n≥1 and a0=4, what is a1?
  1. 9
  2. 11
  3. 12
  4. 13
Show answerHide answer
Answer: B
One update gives a1=3⋅4−1=11. The value 12 performs the multiplication but omits the final subtraction; the rule requires both operations in that order.

Question 5 of 10

Let cn count ordered ways to cover a length-n strip using tiles of lengths 1 and 3. What recurrence and initial values determine cn?
  1. cn=cn−1+cn−2 (n≥2),c0=c1=1
  2. cn=cn−1+cn−3 (n≥3),c0=0, c1=c2=1
  3. cn=2cn−1 (n≥1),c0=1
  4. cn=cn−1+cn−3 (n≥3),c0=c1=c2=1
Show answerHide answer
Answer: D
A final tile has length 1 or 3, leaving a valid strip of length n−1 or n−3. The empty strip counts once, and lengths 1 and 2 each allow only all-unit tiles. Setting c0=0 would discard the tiling consisting of a single length-3 tile when computing c3.

Question 6 of 10

What characteristic polynomial corresponds to an=7an−1−10an−2?
  1. r2−7r+10
  2. r2+7r−10
  3. r2−7r−10
  4. r2+7r+10
Show answerHide answer
Answer: A
Substituting rn and moving all terms to the left gives rn−7rn−1+10rn−2=0. Dividing by rn−2 gives r2−7r+10. Keeping the final coefficient negative copies the recurrence without accounting for the change of side.

Question 7 of 10

Solve an=8an−1−16an−2 for n≥2 with a0=2 and a1=12.
  1. an=(2+3n)4n
  2. an=2⋅4n
  3. an=(2+n)4n
  4. an=(2+n)4n−1
Show answerHide answer
Answer: C
The polynomial is (r−4)2, so write an=(A+Bn)4n. The starting values give A=2 and 4(2+B)=12, hence B=1. Using only 2⋅4n fits the first initial value but gives 8 at index 1, failing to use the second independent solution.

Question 8 of 10

A recurrence has characteristic polynomial (r−3)2(r+2) and forcing n3n. What trial form should be used for a particular solution?
  1. n(An+B)3n
  2. n2(An+B)3n
  3. (An+B)3n
  4. n2(An+B)(−2)n
Show answerHide answer
Answer: B
The forcing is a degree-1 polynomial times 3n, so its polynomial trial is An+B. Since 3 is a characteristic root of multiplicity 2, multiply that whole trial by n2. Multiplying by only n does not clear the full twofold overlap with the homogeneous solutions.

Question 9 of 10

An algorithm creates four equal quarters but recursively solves only three of them. The extra work is 5n. What recurrence models its cost?
  1. T(n)=4T(n/4)+5n
  2. T(n)=3T(n/3)+5n
  3. T(n)=4T(n/3)+5n
  4. T(n)=3T(n/4)+5n
Show answerHide answer
Answer: D
There are three recursive calls, each operating on a quarter of the original input, so their combined cost is 3T(n/4). Add the stated outside work 5n. Using four calls would count the quarter that is created but never recursively solved; the number of pieces is not always the call count.

Question 10 of 10

For an increasing cost on powers of 3, T(n)=9T(n/3)+4n2, what bound does the polynomial-cost master theorem give?
  1. O(n2)
  2. O(n3)
  3. O(n2log⁡n)
  4. O(nlog⁡n)
Show answerHide answer
Answer: C
Here a=9, b=3 and d=2, so a=bd=9. Every internal level has total extra cost 4n2, and there are logarithmically many levels, giving O(n2log⁡n). The bound O(n2) drops that level-count factor in the equality case.
Set 2: Connect roots, coefficients and restrictions10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

For an=2an−1+5 for n≥1 and a0=3, what is the closed form?
  1. an=3⋅2n+5
  2. an=8⋅2n+5
  3. an=8⋅2n−5
  4. an=3+5n
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

Let en count strings of length n over an alphabet of five symbols that contain an even number of one designated symbol. What recurrence and starting value determine en?
  1. en=3en−1+5n−1 (n≥1),e0=1
  2. en=4en−1+5n−1 (n≥1),e0=1
  3. en=5en−1 (n≥1),e0=1
  4. en=3en−1+5n−1 (n≥1),e0=0
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

Solve an=7an−1−12an−2 for n≥2, with a0=3 and a1=10.
  1. an=3n+2⋅4n
  2. an=2⋅4n−3n
  3. an=3⋅3n+4n
  4. an=2⋅3n+4n
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

Solve an=4an−1+3 for n≥1, with a0=2.
  1. an=2⋅4n−1
  2. an=3⋅4n−1
  3. an=4n+1
  4. an=2⋅4n+3
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

For powers of 3, let T(n)=T(n/3)+4 with T(1)=2. What is T(81)?
  1. 16
  2. 22
  3. 10
  4. 18
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

What sequence is represented by x2/(1−x), starting at index 0?
  1. 0,0,1,1,1,…
  2. 0,1,1,1,1,…
  3. 1,1,1,0,0,…
  4. 0,0,2,2,2,…
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

What generating function counts unordered selections from three kinds when the first kind is chosen 1–3 times, the second an even number of times, and the third at most once?
  1. (1+x+x2+x3)(1+x)1−x2
  2. (x+x2+x3)(1+x)1−x
  3. (x+x2+x3)(1+x)1−x2
  4. (x+x2+x3)x1−x2
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

For an=6an−1−8an−2 for n≥2, with a0=2 and a1=7, what is the generating function G(x)?
  1. 2+7x1−6x+8x2
  2. 2−5x1−6x+8x2
  3. 2−x1−6x+8x2
  4. 2−5x1−6x−8x2
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

Three sets have sizes 18, 15 and 13. Their pair-intersection sizes are 6, 5 and 4, and their triple-intersection size is 2. What is the union size?
  1. 31
  2. 29
  3. 46
  4. 33
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

How many integers from 1 through 84 are coprime to 84?
  1. 24
  2. 28
  3. 36
  4. 42
Show answerHide answer

Save this lesson to see this answer.

Set 3: Choose a method and justify the count10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

What contribution belongs to a characteristic root −2 of multiplicity 3?
  1. (A+Bn+Cn2)(−2)n
  2. (A+Bn+Cn3)(−2)n
  3. (A+Bn)(−2)n
  4. (A+Bn+Cn2)2n
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

For an=an−1+2n−1 for n≥1 and a0=0, a proposed formula is an=n2. What expression completes its induction step?
  1. (n−1)2+2(n−1)−1=n2
  2. n2+2n−1=n2
  3. (n−1)2+2n=n2
  4. (n−1)2+2n−1=n2
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

A sequence satisfies an=8an−1−19an−2+12an−3 for n≥3, with a0=3, a1=9 and a2=33. What is its closed form?
  1. an=3n+2⋅4n
  2. an=1+2⋅4n
  3. an=2+4n
  4. an=1+3n+4n
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

Solve an=3an−1+6⋅3n for n≥1 with a0=4.
  1. an=4⋅3n+6
  2. an=(4+2n)3n
  3. an=(4+6n)3n
  4. an=(6+4n)3n
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

For an increasing cost on powers of 4, T(n)=8T(n/4)+3n, what bound does the polynomial-cost master theorem give?
  1. O(n3/2)
  2. O(nlog⁡n)
  3. O(n2)
  4. O(n2/3)
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

If G(x)=1/(1−3x), what is the coefficient of x4 in xG′(x)?
  1. 81
  2. 108
  3. 1215
  4. 324
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

How many unordered selections of 8 objects from three distinguishable kinds are possible if each kind is selected at least once and the first kind is selected at most 3 times?
  1. 21
  2. 15
  3. 18
  4. 12
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

A sequence has generating function G(x)=3/(1−2x)2−1/(1−2x). What is an?
  1. an=(3n−1)2n
  2. an=2⋅2n
  3. an=(3n+2)2n
  4. an=(3n+2)2n−1
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

Of 90 objects, 38 are in A, 32 in B and 27 in C. Pair intersections have sizes 12, 9 and 8, and the triple has size 4. How many are in none?
  1. 72
  2. 18
  3. 22
  4. 14
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

Six distinct tasks are assigned to three labeled teams. How many assignments give every team at least one task and give the first team exactly two tasks?
  1. 240
  2. 180
  3. 210
  4. 420
Show answerHide answer

Save this lesson to see this answer.

Set 4: Solve mixed recurrence and counting problems10 Practice Questions

Save this lesson to see every answer and practice every set.

Question 1 of 10

For strings of length n over symbols “A”, “B” and “C”, let an count those with no adjacent “A” symbols. What recurrence and initial values determine the count?
  1. an=2an−1+2an−2 (n≥2),a0=1, a1=3
  2. an=2an−1+an−2 (n≥2),a0=1, a1=3
  3. an=3an−1−an−2 (n≥2),a0=1, a1=3
  4. an=2an−1+2an−2 (n≥2),a0=0, a1=3
Show answerHide answer

Save this lesson to see this answer.

Question 2 of 10

A degree-4 characteristic polynomial factors as (r−2)2(r+1)2. What is the general solution?
  1. (A+Bn+Cn2)2n+D(−1)n
  2. (A+Bn)2n+(C+Dn)1n
  3. (A+Bn)2n+(C+Dn)(−1)n
  4. A2n+B(−1)n+C22n+D(−1)2n
Show answerHide answer

Save this lesson to see this answer.

Question 3 of 10

Solve an=2an−1+n for n≥1 with a0=1.
  1. an=2n+n
  2. an=2⋅2n−n−2
  3. an=3⋅2n+n−2
  4. an=3⋅2n−n−2
Show answerHide answer

Save this lesson to see this answer.

Question 4 of 10

For powers of 2, T(n)=3T(n/2)+2n and T(1)=1. What is the exact value of T(8)?
  1. 76
  2. 103
  3. 81
  4. 130
Show answerHide answer

Save this lesson to see this answer.

Question 5 of 10

Why does T(n)=T(n/3)+T(2n/3)+n fail the equal-size polynomial-cost master theorem's form?
  1. The extra work is a polynomial in the input size.
  2. The recursive subproblems have unequal sizes.
  3. The recurrence has two recursive calls at each step.
  4. The input size decreases in the recursive calls.
Show answerHide answer

Save this lesson to see this answer.

Question 6 of 10

How many ordered lists of parts of size 1 or 3 have total 7?
  1. 9
  2. 3
  3. 8
  4. 10
Show answerHide answer

Save this lesson to see this answer.

Question 7 of 10

For an=5an−1+2 for n≥1 with a0=3, what generating-function equation is obtained by summing the recurrence?
  1. G(x)−3=5xG(x)+21−x
  2. G(x)=5xG(x)+2x1−x
  3. G(x)−3=5xG(x)+2x1−x
  4. G(x)−3=5(G(x)−3)+2x1−x
Show answerHide answer

Save this lesson to see this answer.

Question 8 of 10

For an=4an−1+3n for n≥1 and a0=2, what closed form follows from its generating function?
  1. an=2⋅4n+3n
  2. an=5⋅4n−3n
  3. an=3⋅4n−3n
  4. an=5⋅4n−3⋅3n
Show answerHide answer

Save this lesson to see this answer.

Question 9 of 10

How many permutations of seven labeled objects fix exactly two objects?
  1. 924
  2. 2520
  3. 882
  4. 1854
Show answerHide answer

Save this lesson to see this answer.

Question 10 of 10

How many nonnegative integer triples satisfy x+y+z=8 with x≤4?
  1. 45
  2. 35
  3. 30
  4. 39
Show answerHide answer

Save this lesson to see this answer.

Stuck on your own question? Homework Help

Key Terms

61 Key Terms, each with its definition

A

Associated homogeneous recurrence
The associated homogeneous recurrence is obtained from a nonhomogeneous recurrence by deleting its forcing term while keeping its coefficients.
The associated homogeneous recurrence for an=3an−1+n is an=3an−1.

B

Base case
A base case gives a result at a terminal size, where no further recursive call is needed.
The merge sort comparison base case M(1)=0 reflects that one item is already sorted.
Big-O bound
A big-O bound gives an eventual upper bound on a function’s magnitude up to a fixed multiplicative constant as the input grows.
The big-O bound O(nlog⁡n) for merge sort does not specify its exact comparison count.

C

Catalan numbers
The Catalan numbers count full parenthesizations of a product, with Cn counting the possible groupings of n+1 factors.
The Catalan numbers give five ways to fully parenthesize four factors before multiplying.
Characteristic equation
A characteristic equation is the polynomial equation obtained by substituting an exponential trial rn into a constant-coefficient homogeneous recurrence.
The characteristic equation r2−5r+6=0 has roots that supply the solution terms 2n and 3n.
Characteristic root
A characteristic root is a solution of the characteristic equation that supplies an exponential building block for the recurrence solution.
A characteristic root of −1 supplies the alternating building block (−1)n.
Closed form
A closed form expresses a sequence term directly from its index, without computing earlier terms.
The closed form an=7+2n lets you find the term at index 100 in one substitution.
Coefficient extraction
Coefficient extraction means finding the multiplier of a specified power in a series, written [xn]G(x) for the power xn.
Coefficient extraction gives [x4](1−x)−2=5 using the standard series expansion.
Complement
A complement consists of objects in a stated universe that do not belong to a specified set, so its size is the universe size minus the set size.
The complement of a union counts objects with none of the properties represented by its sets.
Constant coefficients
Constant coefficients multiply earlier sequence terms by fixed values independent of the index.
The multipliers 5 and −6 are constant coefficients in an=5an−1−6an−2.
Convolution
A convolution combines two sequences by summing products of entries whose indices add to the target index, as in series multiplication.
The convolution at index 2 includes a0b2, a1b1 and a2b0.
Coprime integers
Coprime integers have greatest common divisor 1, so they share no prime factor.
The integers 8 and 15 are coprime integers even though neither number is itself prime.
Counting recurrence
A counting recurrence expresses the number of objects of one size through counts of smaller objects, often by a disjoint split into cases.
A counting recurrence for tiled strips can split the tilings according to the final tile’s length.

D

Degree of a recurrence
The degree of a recurrence here is its largest lag with a nonzero coefficient, indicating how many previous positions the rule reaches back.
The degree of a recurrence an=an−4 is four even though it shows only one earlier term.
Derangement
A derangement is a permutation that leaves no element in its original position.
A derangement of returned labels gives no recipient the label originally assigned to that recipient.
Disjoint cases
Disjoint cases have no objects in common, so their counts can be added without duplication.
Bit strings ending in 0 and bit strings ending in 1 form disjoint cases for counting all endings.
Divide and conquer
Divide and conquer is a method that solves smaller versions of a problem recursively and combines their results to solve the original task.
Merge sort uses divide and conquer by sorting two halves and merging their sorted results.

E

Equality case
The equality case of the polynomial-cost master theorem occurs when a=bd, so each internal level has the same total extra cost.
The equality case gives a logarithmic factor for T(n)=4T(n/2)+n2.
Euler’s function
Euler’s function ϕ(N) counts integers from 1 through N that are coprime to N.
Euler’s function gives ϕ(60)=16 after excluding multiples of 2, 3 and 5.
Extended binomial coefficient
An extended binomial coefficient is (uk)=u(u−1)⋯(u−k+1)/k! for real u and integer k≥1, with (u0)=1.
The extended binomial coefficient (−32)=6 is defined even with a negative upper entry.
Extended binomial theorem
The extended binomial theorem expands (1+x)u for real u with coefficients (uk), giving a series valid for ∣x∣<1.
The extended binomial theorem yields the coefficients of (1−x)−q for positive integer q.

F

Fibonacci numbers
The Fibonacci numbers form the sequence starting with 0 and 1 in which each later term is the sum of the previous two terms.
Domino tiling counts are shifted Fibonacci numbers because their starting values are 1 and 1.
Fixed point
A fixed point is an element that a permutation sends to itself, leaving its position unchanged.
A permutation with exactly one fixed point leaves one object in place and moves every other object.
Forcing term
A forcing term is the added function of the index, independent of earlier sequence values.
In an=4an−1+3n, the forcing term 3n determines the particular-solution trial.
Formal power series
A formal power series is an algebraic series treated through its coefficients, without needing a numerical value or convergence for its variable.
A formal power series lets counting arguments use 1/(1−x) as the sequence of all 1s.

G

General solution
A general solution is a family containing every sequence that satisfies a recurrence, with constants left free until initial conditions are applied.
The general solution (A+Bn)3n has two constants for the double characteristic root 3.
Geometric recurrence
A geometric recurrence multiplies the previous term by a fixed ratio at each step, giving a sequence of the form a0rn.
The geometric recurrence Pn=1.03Pn−1 models a 3% increase per time step.

H

Homogeneous recurrence
A homogeneous recurrence has no added forcing term; every term in its defining equation contains a term of the sequence.
The homogeneous recurrence an=3an−1−2an−2 has no separate function of the index.

I

Inclusion–exclusion
Inclusion–exclusion counts a union of finite sets by adding single-set sizes and alternating subtraction and addition of intersection sizes.
Inclusion–exclusion subtracts shared multiples when counting integers divisible by either of two numbers.
Index shift
An index shift moves the positions of sequence entries; multiplying a generating function by xm inserts m initial zero coefficients.
An index shift by two turns 1/(1−x) into x2/(1−x) with two initial zeros.
Induction hypothesis
An induction hypothesis is the statement assumed for an earlier index or indices while proving that a formula holds at the next index.
The induction hypothesis Hn−1=2n−1−1 is substituted into the Hanoi recurrence.
Initial condition
An initial condition gives a starting sequence value before the recurrence takes over.
Two initial conditions, a0=1 and a1=3, start a rule that uses the previous two terms.
Intersection
An intersection contains objects in all the specified sets, including any that also belong to other sets.
The intersection of multiples of 4 and multiples of 6 consists of all multiples of 12.
Iteration
Iteration solves a recurrence by repeatedly substituting its rule into earlier terms until a starting value is reached.
Iteration of an=2an−1+1 exposes a geometric sum of the accumulated extra terms.

L

Least common multiple
The least common multiple is the smallest positive integer divisible by every given positive integer, defining their common divisibility condition.
The least common multiple of 6 and 10 is 30, so it determines the size of their divisibility overlap.
Level cost
A level cost is the sum of the extra work at every task on one recursion level, excluding the costs of their recursive descendants.
For T(n)=aT(n/b)+cnd, the level cost at depth j is cnd(a/bd)j.
Linear recurrence
A linear recurrence expresses a term as a sum of multiples of earlier terms, possibly with an added function of the index.
The linear recurrence an=2an−1+n has an added term but no products of sequence terms.

M

Master theorem
The master theorem gives growth bounds for equal-size divide-and-conquer recurrences by comparing recursive branching with the extra work.
The polynomial-cost master theorem compares a with bd when the extra work is cnd.
Minimum shift
A minimum shift removes required contributions from the total before extracting a coefficient.
A minimum shift of 6 changes a request for x8 into one for x2 in the remaining product.
Multiplicity
The multiplicity of a root counts the copies of its linear factor in a polynomial.
In (r−4)3(r+1), the root 4 has multiplicity three and the root −1 has multiplicity one.

N

Nonhomogeneous recurrence
A nonhomogeneous recurrence includes an added function of the index that is not identically zero, separate from its earlier sequence terms.
The rule an=2an−1+5n is a nonhomogeneous recurrence with an exponential addition.
Nonlinear recurrence
A nonlinear recurrence has earlier sequence terms combined in a way that is not linear, such as a product or a square of terms.
The Catalan recurrence is a nonlinear recurrence because it multiplies the counts of groupings for the left and right parts of a product.

O

Onto function
An onto function reaches every element of its codomain at least once; it may send several domain elements to the same output.
An onto function from five jobs to three teams gives every team at least one job.
Ordered list
An ordered list distinguishes arrangements with the same contents when the positions of different entries change, so order affects the count.
The ordered lists “112”, “121” and “211” are three ways to arrange the parts 1, 1 and 2 of total 4.
Ordinary generating function
An ordinary generating function is a power series whose coefficient at index n is the term an of the encoded sequence.
The ordinary generating function 1/(1−5x) stores the sequence 1,5,25,125,….

P

Partial fractions
Partial fractions express a rational function as a sum of simpler rational terms whose series coefficients can be read from standard expansions.
Partial fractions split (1−x)/((1−2x)(1−3x)) into −1/(1−2x)+2/(1−3x).
Particular solution
A particular solution is any one sequence satisfying the full nonhomogeneous recurrence.
The constant sequence −1 is a particular solution of an=2an−1+1.

R

Rational generating function
A rational generating function is a quotient of polynomials, which often results when a constant-coefficient linear recurrence is summed.
The rational generating function (1−x)/((1−2x)(1−3x)) can be split into geometric series.
Recurrence relation
A recurrence relation is a rule that expresses each sequence term using earlier terms over a stated range of indices.
The recurrence relation an=an−1+4 adds four at each update from its starting value.
Recursion level
A recursion level groups tasks reached after the same number of recursive size reductions.
At recursion level j, a rule with a calls per task has aj tasks of size n/bj.
Repeated denominator factor
A repeated denominator factor is a power of a linear factor whose series expansion contributes an index polynomial times an exponential.
The repeated denominator factor (1−2x)2 gives coefficients (n+1)2n in its reciprocal.
Repeated root
A repeated root is a characteristic root with multiplicity greater than one, requiring index powers as well as its exponential term.
A repeated root 2 of multiplicity two supplies both 2n and n2n in the solution.

S

Selection factor
A selection factor is the series for one kind of item, with each allowed exponent recording an allowed contribution to the selected total.
The selection factor x+x2+x3 permits one, two or three items of that kind.
Shifted sum
A shifted sum rewrites recurrence terms with changed indices in terms of a full generating function and the starting terms excluded by the range.
The shifted sum ∑n≥2an−1xn becomes x(G(x)−a0).
Sieve of Eratosthenes
The sieve of Eratosthenes finds primes by removing composite multiples of smaller primes, leaving primes after 1 is excluded.
A sieve of Eratosthenes up to 100 uses 2, 3, 5 and 7 to remove every composite number.
Subproblem
A subproblem is a smaller instance of the task being solved by a recursive algorithm.
A binary search continues with one subproblem even though its comparison separates two halves.

U

Undetermined coefficients
Undetermined coefficients is a method that chooses a particular-solution form and finds its unknown constants by substitution and coefficient matching.
Undetermined coefficients uses An+B as the polynomial part of a trial for linear forcing.
Union
A union contains every object in at least one specified set, counting shared objects once.
The union of three divisibility sets counts integers satisfying one or more of the divisibility rules.
Unordered selection
An unordered selection is determined by how many objects of each kind are chosen, with different arrangements of those objects treated alike.
An unordered selection with two parts of size 1 and one part of size 2 is counted once.
Unrolling
Unrolling expands a recurrence through successive recursive levels until the base tasks and accumulated extra costs are visible.
Unrolling T(n)=T(n/2)+3 adds one cost of 3 for each halving before the base case.

V

Violation set
A violation set contains objects that fail one required condition, allowing inclusion–exclusion to remove objects failing any condition.
For the upper bound x≤4, the violation set consists of solutions with x≥5.

About this lesson

By StudeliReport a mistake

Make your own Study Materials

Turn your notes, slides and documents into Study Guides, Practice Questions, Flashcards and 6 more tools.

Get Started