Learn

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Lesson 3 of 34

Track inversions with a generating polynomial

Derive the inversion insertion recurrence.

Loading your saved responses…

Try the optional starting-point checks and targeted refreshers. You can continue directly into this lesson.

Try

In the permutation 3, 1, 2, the label three appears before both smaller labels, creating two inversions. An inversion is a pair of positions i< j whose values satisfy π_i>π_j. Counting inversions measures disagreement with increasing order, but different permutations can have the same count. We will retain the entire distribution in a polynomial rather than summarize it by a single average.

Predict

Predict what happens when the largest label is inserted into a shorter permutation. It creates one inversion with every entry after it and none with entries before it. Its possible contribution is therefore any integer from zero through n−1, exactly once for each insertion position. The old inversions remain unchanged because the relative order of all old labels is preserved.

Experiment

List all permutations of three labels and group them by inversion count.

CountPermutationsCoefficient
01231
1132, 2132
2231, 3122
33211

Thus the polynomial is 1+2q+2q²+q³=(1+q)(1+q+q²). Check the total at q=1 and the signed difference at q=−1. These evaluations answer different questions about the same coefficient distribution.

Understand

Define I_n(q)=Σ over permutations π of q^(inv (π)), with I_0(q)=1 for the empty permutation. The insertion bijection proves I_n(q)=(1+q+…+q^(n−1))I_(n−1)(q). Iteration gives the q-factorial product. Its degree is N=C(n, 2), the inversion count of the reverse permutation. Reversing the positions of any permutation changes every inverted pair into a noninverted pair and conversely, proving q^N I_n(1/q)=I_n(q) as a polynomial identity after clearing negative powers. This symmetry is a combinatorial involution, not an accidental numerical pattern in the first few rows.

Apply

A related q-enumeration counts binary words with r ones and s zeros, weighting a word by its number of one-before-zero pairs. Let F(r, s) be the polynomial. Splitting by the final letter gives F(r, s)=F(r−1, s)+q^r F(r, s−1), with F(0, s)=F(r, 0)=1. At q=1 this becomes the binomial recurrence and counts C(r+s, r) words. These are Gaussian binomial polynomials, a refinement of binomial coefficients. The recurrence proves that their coefficients are nonnegative integers even if a later quotient-of-products expression obscures that fact.

The Gaussian binomial also has the product expression F(r, s)=product from i=1 to r of (1−q^(s+i))/(1−q^i). To verify it without assuming polynomial division works, treat the expression as a rational function and check the boundary values and the proved recurrence. Dividing the two recurrence terms by the proposed product gives respectively (1−q^r)/(1−q^(r+s)) and q^r(1−q^s)/(1−q^(r+s)); their sum is one. Induction identifies the rational expression with the counting polynomial, proving its apparent denominators cancel.

Continue

Use insertion to construct a permutation with a specified inversion count: choose the number created at each stage, respecting its range. Explain why arbitrary independent counts outside those bounds do not decode. For a uniform random permutation, indicator variables give expected inversions N/2 because each label pair has either order with equal probability; pairwise independence is unnecessary. This lesson concerns a formal counting variable q, not a probability or a field size unless another interpretation is explicitly introduced.

Return to the combinatorics and graph theory unit for prerequisite choices and targeted retries. Continue with count unlabeled blocks of labeled objects.

Apply · explain · revise

Practice and reasoning

Drafts save locally as you type. Reveal worked solutions when useful; the site remembers that exposure. Automatic matches check the requested answer, while written arguments require review against the rubric.

Find the number of inversions in permutation (3, 1, 4, 2).

Integers, fractions and finite decimals are accepted. Expressions such as sqrt(2) are not parsed by this checker.

How many permutations of three labels have exactly one inversion?

Integers, fractions and finite decimals are accepted. Expressions such as sqrt(2) are not parsed by this checker.

Prove the inversion generating polynomial is product from j1 to n of (1+q+…+q^(j−1)).

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Prove coefficients for k and C(n, 2)−k agree.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Find and justify the mean inversion count in a uniform random permutation.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Explain the recurrence for binary words with r ones and s zeros, weighted by one-before-zero pairs.

Structure your argument and preserve revisions

These optional planning fields save locally. Recording your response saves an immutable copy of the argument and these fields. Older records may contain only first/latest responses; missing intermediate revisions are not reconstructed.

Each field allows 2,000 characters. Keep a specific claim, state where it applies, cite the facts you use, and explain what still needs checking. Blank fields are allowed and are not evidence of mastery.

Reflect and continue

Before marking this lesson complete, explain one key idea without the worked solution and identify a condition that matters. Marking complete records participation, not independent mastery.