I have recently been asked this question and was a little confused as I don’t have a good grip on Sorting algorithms.
An array A contains ‘I’ number of inversions then what is the time
complexity of insertion sort algorithm to sort the array A (of size n)
As the questions says, this is how inversions are defined:
Given an array arr[]. Two elements arr[i] and arr[j] form an inversion
if a[i] > a[j] and i < j.
I wanted to understand both the best case and the worst case scenarios of the situation.
3