Solution: Inversion Count in a List
This lesson explains how to calculate inversion count in a divide and conquer paradigm.
We'll cover the following...
We'll cover the following...
Solution: 1
The naive solution to this problem would be to:
- Pick an element from the list
- Compare it with all elements to its right
- If the element on the right is smaller, increment the inversion count
Time complexity
The list is traversed once for each element in it. It runs in , thus, it is inefficient.
...