Java programming
Let a[0..n-1] be an array of n distinct integers. A pair (a[i], a[j]) is said to be an inversion if these numbers are out of order, i.e., i j but a[i] > a[j]. For example: if array a contains the following numbers: 9, 8, 4, 5 then the number of inversions is 5. (inversions are …