vector<int>merge_sort(vector<int>arr,long&swapCount){if(arr.size()<=1)returnarr;size_tmid=arr.size()/2-1;vector<int>left=vector<int>(arr.begin(),arr.begin()+mid+1);vector<int>right=vector<int>(arr.begin()+mid+1,arr.end());left=merge_sort(left,swapCount);right=merge_sort(...
In an array, , the elements at indices and (where ) form an inversion if . In other words, inverted elements and are considered to be "out of order". To correct an inversion, we can swap adjacent elements. For example, consider the dataset . It has two inversions: and . To sort th...