1.

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

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.



Discussion

No Comment Found

Related InterviewSolutions