in Algorithms retagged by
354 views
0 votes
0 votes

 

 

Ans given is option-B

in Algorithms retagged by
354 views

1 Answer

0 votes
0 votes
Yes that's right because

A) insertion sort would need O(n) space for data and O(n) stack space.

C) merge sort would take O(n) data space and O(n logn) stack space. Hint: it is an outplace algorithm

D) same as A

B) takes O(n) data space and O(logn) stack space in all cases except the worst.

4 Comments

@vikas

Space complexity of insertion sort is O(1) noe?
0
0
Yes, but for iterative algorithm. Here the question is of the recursive algorithm which uses a stack.
0
0
Thanks
0
0