Math, asked by honeygarg29771, 1 year ago

Find number of inversions in an array. Inversion means a pair where a[i] > a[j] and i

Answers

Answered by noonenothing354
0

Step-by-step explanation:

Count Inversions in an array | Set 1 (Using Merge Sort)

Inversion Count for an array indicates – how far (or close) the array is from being sorted. If array is already sorted then inversion count is 0. If array is sorted in reverse order that inversion count is the maximum.

Formally speaking, two elements a[i] and a[j] form an inversion if a[i] > a[j] and i < j

Example:

The sequence 2, 4, 1, 3, 5 has three inversions (2, 1), (4, 1), (4, 3).

Similar questions