Рет қаралды 9,954
Given an array A[1,n] of numbers, we need to count the number of inversions.
As inversion is a pair of positions (i, j), such that i is smaller than j, but i-th element is larger than j-th element (i.e, the elements are out of order with respect to sorted order). This can be solved in O(n log n) time via a Divide and Conquer algorithm.