Open In App
Related Articles

Algorithms | Misc | Question 9

Improve Article
Save Article
Like Article

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

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 28 Jun, 2021
Like Article
Save Article
Similar Reads