I want to sort a set of data using C implementation. I wonder which sorting is efficient and best case in time-complexity. Note that, the data are in ascending order only. I want to sort it to descending order. Which one is more efficient & least efficient and why?
Can anybody explain it with reason?
I want to sort a set of data using C implementation. I wonder which
Share
In that specific case you don’t have to use a sorting algorithm as such. For example you can just swap the
ith element with then - ith element:This has always the complexity
O(n/2). I dont’t think that there is a much faster way. Apart from just reading the data in the other direction of course.