in Programming in C
1,743 views
1 vote
1 vote
Which of the following algorithm have the smallest memory requirement i.e Low space complexity including data space and run time stack for recursive calls.

A)insertion sort

B)quick sort

C)merge sort

D)selection sort
in Programming in C
1.7k views

1 Answer

3 votes
3 votes
Merge and quick sort are recursive algorithms, needs stack the most.

Well, both selection and insertion are in-place and O(1) space complexity.

Selection sort needs more variables than Insertion sort.

So, According to me, insertion sort should be the answer.

1 comment

merge sort -no, it require extra space since it is out of place algorithm also require stack

quicksort-recussive algo and require stack

in between insertion and selection  , insertion sort require less variables

so ans is insertion sort
0
0

Related questions

1 vote
1 vote
3 answers
3