Is it possible to stably sort an array in O(n log n) with constant auxilliary space?

StackOverflow https://stackoverflow.com/questions/19275537

  •  30-06-2022
  •  | 
  •  

Given an array of n elements, is there a sorting algorithm that

  1. sorts in at most O(n log n) time (and optionally, O(n) time in the best case)
  2. is stable
  3. takes O(1) auxilliary space

All sorting algorithms I found satisfy only two of these criteria:

  • bubble sort satisfies 2 and 3
  • merge sort satisfies 1 and 2
  • heap sort satisfies 1 and 3

Is there an algorithm that satisfies all three criteria?

有帮助吗?

解决方案

From: https://cstheory.stackexchange.com/

There exists a stable in-place sorting algorithm with O(n log n) comparisons and O(n) moves.

See: Gianni Franceschini: Sorting Stably, in Place, with O(n log n) Comparisons and O(n) Moves. Theory Comput. Syst. 40(4): 327-353 (2007) Link

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top