Giant Panda
last year
Giantcountry asked

In space complexity, do we measure memory as auxiliary space, input space, or both?

Abhay Jajodia
Expert
last year
Abhay Jajodia answered

Hi Giant,

It depends on what the author or course means by space complexity.

  • Auxiliary space means extra memory the algorithm uses, not counting the input itself.

  • Space complexity often means total space used, which can include both input space + auxiliary space.

In many algorithm discussions, people focus on auxiliary space because the input size is usually fixed by the problem, and they want to compare how much extra memory different solutions need.

If you have more questions, I am here to help 😊

Python
This question was asked as part of the Complexity Calculation course.