On Improving a Sorting Algorithm

Every array of numbers, if unsorted, will have inversion, which is an ordered pair \((i, j)\) where \(i < j\) but \(A[i] > A[j]\). The average number of inversions in an array of size \(N\) is \(\frac{N(N - 1)}{4}\) which is also \(\Omega(N^2)\).

For algorithms that only perform adjacent swaps, such as 202202220937, 202202232135 and 202202232215, will only able to run \(\Omega(N^2)\) on average time since exactly one inversion will be resolved after each comparison.

To solve this, one need to eliminate more than one inversion in order to achieve at least \(o(N^2)\) running time.

Links to this page
#algorithm #sorting