[Solved] Under what condition the number of inversions in an array is maximum?

Under what condition the number of inversions in an array is maximum?

a) when the array is sorted
b) when the array is reversely sorted
c) when the array is half sorted
d) depends on the given array

Answer: b
Explanation: The number of inversions in an array is maximum when the given array is reverse sorted. As the necessary condition for an inversion is arr[i]>arr[j] and i<j.

Comments