+1 vote
in Data Structures & Algorithms II by (110k points)
What is the space complexity of in place merge sort?

(a) O(1)

(b) O(n)

(c) O(log n)

(d) O(n log n)

This question was addressed to me in semester exam.

This intriguing question comes from Sorting in section Sorting of Data Structures & Algorithms II

1 Answer

+1 vote
by (614k points)
selected by
 
Best answer
The correct answer is (c) O(log n)

Easiest explanation - Space complexity of in place version of merge sort is O(log n) which is used for storing call stack formed due to recursion. Note that the algorithms with space complexity as O(log n) also qualifies as in place algorithms as the value of log n is close to 1.

Related questions

Welcome to TalkJarvis QnA, a question-answer community website for the people by the people. On TalkJarvis QnA you can ask your doubts, curiosity, questions and whatever going in your mind either related to studies or others. Experts and people from different fields will answer.

Categories

...