Algorithms | Misc | Question 9

An inversion in a an array A[] is a pair (A[i], A[j]) such that A[i] > A[j] and i < j. An array will have maximum number of inversions if it is:
(A) Sorted in increasing order
(B) Sorted in decreasing order
(C) Sorted in alternate fashion
(D) Both A and B


Answer: (B)

Explanation: If the array is sorted in decreasing order, each pair will be an inversion.
e.g. 5, 4, 3, 2, 1
Maximum number of inversions possible = n * (n – 1) / 2 where n is the size of the array.

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.