I have read something in the site that inversion means if i<j then A[i]>A[j] and it has some exercises about this , I have a lot of questions but I want to ask just one of them at first and then i will do the other exercises by myself if I can!!
Exercise: What permutation array (1,2, …, n) has the highest number of inversion? What are these?
thanks
Clearly
N, ..., 2, 1has the highest number of inversions. Every pair is an inversion. For example forN = 6, we have6 5 4 3 2 1. The inversions are6-5, 6-4, 6-3, 6-2, 6-1, 5-4, 5-3and so on. Their number isN * (N - 1) / 2.