« Space complexity analysis for merge sort

Space complexity analysis for merge sort

At any point of time there will be only one function which would have created an additional array. When we reach function(n) both functions function(n/2) would have completed their work so there won't be any additional array from them.

At the base case there will be log(n) functions waiting in the stack and each function will be taking some k space. So at the base case k(log(n)) space being used by the call stack.

mergesort_space_complexity.jpg