226 views
Which algorithm has smallest memory requirement in terms of data space and runtime stack(for recursive calls)? (Low Space Complexity)

A. Insertion sort

B. Selection sort

C. Quick Sort

D. Merge Sort

+1 vote
• C and D cannot be the answer , since they require stack for recursive calls.
• A and B , both are inplace sort and have Space complexity of O(1).

### The answer should be A .. insertion Sort because in best case the number of comparisons become O(n).

C.Quick Sort is Inplace algorithm with max O(n^2) only for ascending or descending order elements.
Please specify space complexity for all.

What about sorting technique that by default have no runtime stack?

So if we have no runtime stack for sorting, that sorting should become more selective over sorting with runtime stack.

So, quick sort is having runtime stack, so it should not answer.

Correct me if I am wrong.
why not A and B?  I think Quicksort space complexity will be more than Insertion or selection, we even dont need any recursion for A and B and for quicksort we need atleast one recursion call.