Skip to content
Related Articles

Related Articles

Improve Article

Algorithms | Misc | Question 9

  • Last Updated : 28 Jun, 2021
Geek Week

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
Recommended Articles
Page :