Discuss the space complexity of merge sort and how it compares to other sorting algorithms.

  • O(log n)
  • O(n log n)
  • O(n)
  • O(n^2)
Merge sort has a space complexity of O(n) due to its need for additional memory. This is more efficient than algorithms with higher space complexity, like quicksort with O(n^2) in the worst case, making merge sort advantageous in terms of space usage.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *