All sorting algorithms on random-access arrays require O(lg(n)) space. Consider the size of the array indices. It requires ceil(lg(n)/lg(2))
bits to represent an array index variable that can hold n distinct values. If your data is in a random-access array, you will need at least one such variable. Therefore, there is a minimum bound of O(lg(n))
on your space complexity, regardless of what algorithm you use.
Note that mergesort cannot avoid this either. You can either have mergesort run in-place, in which case all merge phases (of which there are O(lg(n))
) run in parallel for O(lg(n))
space complexity, or you do a non-in-place sort with O(n)
space complexity, or you overwrite your input array, in which case you need that index variable again.
Because this bound is rather fundamental (and typically not a problem), usually one does not bother mentioning it.