[Solved] How many inversions are there in the array arr = {1,5,4,2,3}?

How many inversions are there in the array arr = {1,5,4,2,3}?

a) 0
b) 3
c) 4
d) 5

Answer: d
Explanation: The necessary condition for an inversion is arr[i]>arr[j] and i<j. So there are 5 inversions in the array.

Comments