Category: inversion

Counting inversions in an subarrays

Given an array arr[], the goal is to count the number of inversions in all the sub-arrays. An inversion is a pair of indices i and j such that i > j and arr[i] < arr[j]. A sub-array from index x to y ( x= j.Naive Approach: A naive approach is to generate all possible […]

Continue Reading