Considerations for space complexity analysis

There is a lot of information on time complexity analysis. For example, we know that for calculating the time complexity we study the number of operations (e.g. traversal, swapping, comparisons etc.) an algorithm performs.

I have not been able to lay my hands on the considerations for space complexity analysis.

Q) What are the main considerations in space complexity analysis?

• For calculating the space complexity we study the number of memory locations (e.g. variables, arrays, data structures etc.) an algorithm uses.
– user16034
Jul 16, 2022 at 9:12

• Numbers, letters (not full strings however!) and all other "primitive" types are usually considered with $$O(1)$$ space (even though that's not entirely correct).
• Lists with $$n$$ elements, or strings with $$n$$ letters - take $$O(n)$$ space
• Any other data structure takes whatever memory needs for its components (for example, if we have a structure holding two lists, the first with $$k_1$$ elements and the second with $$k_2$$ elements - then the storage will take $$O(k_1+k_2)$$)