Answer the question
In order to leave comments, you need to log in
How to determine the number of inversions for a permutation?
It is necessary to determine the number of inversions and indicate a common feature for those numbers n for which this permutation is even and odd.
1, 4, 7, ... , 3n-2, 2, 5, 8, ... , 3n-1, 3, 6, 9, ... , 3n
Please explain the algorithm for solving this type of problem using this example.
Answer the question
In order to leave comments, you need to log in
Inversion is when a < b, but they cost the other way around.
Within a block (for example, 1…3n−2), of course, there are no inversions.
Between the first and second block.
• With 2: 4, 7,… That is, n−1 pcs.
• From the 5th: starting from the 7th — that is, n−2 pcs.
• Total 0 + 1 + 2 +…+ (n−1) = n(n−1)/2 pcs.
Between the first and third, and between the second and third, can you calculate the inversions yourself? And whether it is even or not is also, I hope, easy to calculate.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question