根據geekforgeeks:輔助複雜的排序修飾
Auxiliary Space is the extra space or temporary space used by an algorithm. Space Complexity of an algorithm is total space taken by the algorithm with respect to the input size. Space complexity includes both Auxiliary space and space used by input.For example, if we want to compare standard sorting algorithms on the basis of space, then Auxiliary Space would be a better criteria than Space Complexity. Merge Sort uses O(n) auxiliary space, Insertion sort and Heap Sort use O(1) auxiliary space. Space complexity of all these sorting algorithms is O(n) though.
但是,假設一個場景,一個修改歸併排序,在那裏是return
一個全新的有序數組保持輸入陣列不變。
new sorted array which is returned
會被視爲temporary space
? 換句話說,輔助複雜性still
是O(n)和空間是O(n)?