Question: You are given an array a . An ordered tuple of integers ( i , j ) where i < = j is said to

You are given an array a. An ordered tuple of integers (i, j) where i <= j is said to be incompatible if a[j]< a[i].
Please tweak the merge sort algorithm to calculate the number of incompatible tuples of integers for a given array a.
Example: a =[1,2,3,4,5,2,1]. For this test case, j =5 is incompatible with i =2,3,4. Also j =6 is incompatible
with i =1,2,3,4,5. So the answer is 8.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!