2

I saw in wiki and some other text, they said space complexity of bubble sort, insertion sort, selection sort, etc is O(1) auxiliary. Are they referring to constant memory cells that will be required for variable used in programs.

2 Answers 2

4

Yes they are referring to the fact that most sorts are in place sorts so they have a constant memory use. If the sort was not in place then it would require O(n) extra memory at the minimum.

Sign up to request clarification or add additional context in comments.

2 Comments

And for something like quicksort, the auxiliary space is O(log n) because of the recursions.
About "in-place": Since in-place uses the existing memory used for the unsorted list (usually just swapping elements within there), the additional "auxilary" memory for any algorithm variables is what is paid attention since that is the "extra space" cost [beyond the original space of the list itself].
-1

If an algorithm works without any addition space or memory it's called "in situ"

http://en.wikipedia.org/wiki/In_situ

An algorithm is said to be an in situ algorithm, or in-place algorithm, if the extra amount of memory required to execute the algorithm is O(1)

1 Comment

This is true, but is tangential to answering the question (it does not answer it). And "in situ" is just a synonym for the more common "in-place".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.