Key Insight:(2,3,β¦,m,1) has mβ1 inversions, so moving the first input to the last slot multiplies Ξ± by (β1)mβ1.
IICounting Inversions Swap by Swap
Every swap of two entries changes the number of inversions by an odd number, so the sign flips each time.
IIIWhere the Odd Change Comes From
The swapped pair changes the count by Β±1; each entry between them changes it by 2, β2 or 0.
IVQuiz Questions
Problem 1 Β· Count the Inversions
Given: the permutation (3,1,4,2)βperm4. Find its number of inversions N and its sign.
How many inversions?
What is the sign?
β Correct! The inversions are {1,3}, {2,3} and {2,4}, so the sign is (β1)3=β1.
β Not quite. An inversion need not be two neighbours: 2 comes after 3 even though 1 and 4 sit between them.
β Not quite. Check all (24β)=6 pairs of numbers and ask whether the smaller one appears after the larger.
β Check the sign. The sign is (β1)N with N the number of inversions.
Show solution
Check the six pairs of numbers in the list 3,1,4,2:
{1,2}, {1,4}, {3,4}: the smaller number comes first, natural order.
{1,3}: 1 comes after 3. {2,3}: 2 comes after 3. {2,4}: 2 comes after 4. These are inversions.
So N=3 and sign(3,1,4,2)=(β1)3=β1.
Problem 2 Β· A Cyclic Rearrangement
Given:Ξ±βValt(3)β and v1β,v2β,v3ββV. ExpressΞ±(v2β,v3β,v1β) in terms of Ξ±(v1β,v2β,v3β).
β Correct!(2,3,1) has two inversions, so its sign is +1.
β Not quite. Moving v1β to the end looks like one move, but it takes two swaps: (2,3,1) has mβ1=2 inversions.
β Not quite. No input is repeated and nothing says the list is dependent; rearranging can only change the sign.
β Not quite. Rearranging inputs multiplies the value by the sign of the permutation, which is Β±1.
Show solution
The inputs are vj1ββ,vj2ββ,vj3ββ with (j1β,j2β,j3β)=(2,3,1). Its inversions are {1,2} and {1,3} (1 appears after both), so N=2 and the sign is +1:
Check with swaps: swapping slots 1 and 3 gives βΞ±(v1β,v3β,v2β), and swapping slots 2 and 3 gives Ξ±(v1β,v2β,v3β).
Problem 3 Β· After One Swap
Given: a permutation with 7 inversions. Two of its entries are swapped. Which number could be the new number of inversions?
β Correct! A swap changes the count by an odd number, and 4β7=β3 is odd.
β Not quite. That is a change of Β±2, an even number. A swap always changes the number of inversions by an odd number.
β Not quite. A change of 0 is even; the swapped pair alone contributes Β±1 and everything else contributes an even amount.
β Not quite. Use the parity of the change.
Show solution
Swapping two entries changes the number of inversions by Β±1 (the swapped pair) plus 2, β2 or 0 for each entry between them, plus 0 for every other pair. The total change is odd.
From 7: a new count of 9, 5 or 7 would be a change of +2, β2 or 0, all even. Only 4 (a change of β3) is possible. In general, a swap turns an odd count into an even one and an even count into an odd one.
Problem 4 Β· Reversing Six Inputs
Given:Ξ±βValt(6)β and v1β,β¦,v6ββV. ExpressΞ±(v6β,v5β,v4β,v3β,v2β,v1β) in terms of Ξ±(v1β,β¦,v6β).
β Correct! Every one of the 15 pairs is out of order, and (β1)15=β1.
β Not quite. Three swaps (v1ββv6β, v2ββv5β, v3ββv4β) restore the order, and three is odd.
β Not quite. A rearrangement multiplies Ξ± by Β±1. Count the inversions of (6,5,4,3,2,1).
Show solution
In (6,5,4,3,2,1) every smaller number appears after every larger one, so all (26β)=15 pairs are inversions. Hence