Space Complexity
Still in preparation. Please check the references at the end of the document.
“Space: the final frontier.” - Captain Kirk
Today we will begin the study of another important resource in computation: the space complexity of algorithms. The space complexity of a given problem is the optimal amount of memory used by any algorithm that solves the given problem.
Space Complexity
Before we define the classes of problems based on space complexity, we need to define what we mean by the space used by a Turing machine.
Note that it is important to distinguish in the case of space complexity between the space used by the work tape and the space used by the input tape, as we will want to study machines which use an amount of work space which may be smaller than the input size. In this case, we consider the input tape to be read-only, and the work tape to be used for computation.
This is a slight distinction between space and time, as a machine which runs in time sublinear in the input size cannot even read the entire input, and thus cannot really solve any interesting problems.
To study space complexity, we need to define the space cost of a given Turing machine.
Definition 1: The (worst-case) space cost of a Turing machine
For every function
Analogously to the study of time, we can define the classes
For every function
For every function
With the above definitions, we can define the following classes:
Class | Definition |
---|---|
Note that
Proposition 1:
Proof: It is enough to show that
The above proof can be generalized to show that
Proposition 2:
As it turns out,
Proposition 3: The language TQBF is in
The proof of Proposition 3 is quite similar to the proof of Proposition 1, as the TM which decides TQBF simply has to brute-force all possible assignments to the variables, keeping track of the quantifier being tested.
Acknowledgements & References
This lecture was based on these resources:
- Lecture notes by Prof. Eric Blais.
- [S13, Chapter 8]
- [AB09, Chapter 4]