AI engineering glossary · Data structures algorithms

What is space complexity?

Space complexity: The amount of extra memory an algorithm needs as a function of input size, usually not counting the input itself. It matters when data is large or memory is limited, such as on a phone or a small server.

Level: beginnerTopic: Data structures algorithms

Space complexity: an example

Reversing a list by building a new list uses O(n) extra space. Swapping elements from both ends within the same list uses O(1) extra space.

Related terms

More Data structures algorithms terms

Where you learn it

Space complexity is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.