Space Complexity

Space complexity describes how much memory an algorithm needs as input size grows.
Also known as
memory complexity

Intuition

A fast method can still fail if it needs too much memory.

Technical definition

Space complexity is the asymptotic memory required by an algorithm, including auxiliary data structures and sometimes input storage depending on convention.

Example

A dynamic programming algorithm may trade extra memory for faster computation.

Common misunderstandings

  • Low time complexity does not imply low memory use.
  • Memory access patterns can matter as much as total memory volume.

Need this inside a product?

The studio builds the systems these terms describe. Tell us what you are working on.