I am working in a program that handles data. However because i want my code efficient I would like a sorting algorithm that its running time does not depend on the number of inversions that the array has so i can sort it in ascending order. The order of the arrays is always:
n = array's size
list = (1,2,3,...,(n/2 -1), (n/2),(n/2 + 1),...3,2,1
I know the arrays has a total of inversions equal to:
- (n/2 -1) + (n/2 -2) + (n/2 - 3) +...+ 1
I think that is a lot of inversions for a symmetrical array and because I know the order of the array is always like that I would like an algorithm to sort them in O(n) time. I know Insertion Sort's complexity is dependent on the number of inversions the array has but I am not sure what is the number of inversions of the array dependent on n