Question: LetA [ 1 . . . n ] be an array of n distinct numbers. If i < j and A [ i ] >

LetA[1... n] be an array of n distinct numbers. If i < j and A[i]> A[j], then the pair
(i, j) is called an inversion of A.
(a) What is the maximum number of inversions an array A can have?
(b) What is the minimum number of inversions an array A can have?
(c) determine the inversions of A =<3,16,1,5,8,4,7> list them all
(d) provided modify the insertion-sort algorithm so that the algorithm counts the
total number of inversions
(e) Suppose A[1... n] and B[1... n] are two arrays with identical elements (not neces-
sarily same order). Professor Stooge has hypothesized that if these two arrays have the
same number of inversions then the order of the arrays are identical. Is Professor Stooge
correct? Explain.

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 Databases Questions!