Inversion count for an array indicates - how far the array


We have to count Inversions in a given array.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).

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Inversion count for an array indicates - how far the array
Reference No:- TGS01516383

Now Priced at $10 (50% Discount)

Recommended (91%)

Rated (4.3/5)