Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stable comparison sort with O(n * log(n)) time and O(1) space complexity

While going through Wikipedia's list of sorting algorithms I noticed that there's no stable comparison sort that has O(n*log(n)) (worst-case) time-complexity and O(1) (worst-case) space-complexity. This surely looks like a theoretical boundary, but I couldn't find more information about it.

How would one proof this?

Note: I know about the lower limit of O(n*log(n)) worst-case time-complexity for comparison sorts.

like image 350
Florian Brucker Avatar asked Mar 19 '12 20:03

Florian Brucker


People also ask

Which sorting algorithm is best in time and space complexity?

Bucket sort – Best and average time complexity: n+k where k is the number of buckets.

Why is space complexity of selection sort O 1?

In each iteration of the selection sort algorithm, we find the minimum values element for the unsorted part of the array and then move it to the sorted part. The space complexity of the selection sort algorithm is O ( 1 ) O(1) O(1) as we are not using any extra space rather than two variables namely min and i.

Which sorting method is stable?

Several common sorting algorithms are stable by nature, such as Merge Sort, Timsort, Counting Sort, Insertion Sort, and Bubble Sort. Others such as Quicksort, Heapsort and Selection Sort are unstable.


1 Answers

Despite what that article says, in-place stable Merge Sort can be made O(n log n).

Here is a paper that explains two ways to implement it.

like image 79
BlueRaja - Danny Pflughoeft Avatar answered Sep 22 '22 16:09

BlueRaja - Danny Pflughoeft