2.Read the number of elements and store them in an array. 3.Use a modified merge sort to count inversions: .Recursively split the array into halves and count inversions in each half. .While merging ...
An **inversion** in an array is a pair of elements such that the earlier element is greater than the later element. For example, in the array `[2, 4, 1, 3, 5]`, the pairs `(2, 1)`, `(4, 1)`, and `(4, ...