G
G
graynberg2016-10-09 16:43:53
Mathematics
graynberg, 2016-10-09 16:43:53

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

1 answer(s)
M
Mercury13, 2016-10-10
@Mercury13

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 question

Ask a Question

731 491 924 answers to any question