Space Compl
Space Compl
THEORY OF COMPUTATION
PRESENTED BY :
22CSU169- SOURISH
22CSU171- SRISHTI
22CSU172- SURYANSHU
22CSU175- TANISHA
22CSU173- SUSHANK
Introduction to Space Complexity
WHAT IS SPACE COMPLEXITY ?
Space Complexity is the maximum number of tape cells a Turing Machine (TM)
uses during the computation on any input of size n.
That is, it measures how much memory the machine uses while processing an
input.
This memory is measured in terms of tape cells visited or modified during the
computation.
While time complexity counts the number of steps,
Space complexity counts the number of cells used (not necessarily the full length
of the input tape).
Applies to: Deterministic TMs and Non-deterministic TMs
Importance of Studying Space Complexity
Determines if a problem can be solved within realistic memory
limits.
Crucial for embedded systems, IoT, and memory-constrained
computation.
Helps define computational boundaries via complexity classes (e.g.,
L, PSPACE).
Used in streaming algorithms, compiler optimizations, and security
protocols.
Key Space Complexity Classes
Class Full Name Space Bound TM Type
This refers to the maximum number of distinct tape cells that M reads from or writes to on any
branch of its computation.
Examples :- Action Memory Used? Why?
Overwriting
symbols
❌ Not counted Replaces input in-
place (0→x, 1→y)
The TM:
Uses only a constant number of states.
Scans and rewrites the same tape repeatedly.
Space Complexity =O(n) For input of length 2n (with n 0s and n 1s), it uses:
No extra space outside of input tape.
In-place marking: counts as O(n) cells written (since
every character might be rewritten once).
MULTIPLE CHOICE QUESTIONS
1. What does the space complexity of a Turing machine measure?
Answer: C
Explanation: Space complexity is the maximum number of tape cells a Turing Machine scans or uses (writes to) during computation.
Answer: A
Explanation: Input tape is read-only and doesn't count toward space complexity.
3. A TM that only moves its head right and never writes any new symbols uses how much space?
A. O(1)
B. O(log n)
C. O(n)
D. O(n²)
Answer: A
Explanation: If it doesn’t write or store any variables and just scans, it uses constant space.
16. If a TM modifies O(log n) cells on input of size n, what is its space complexity?
A. O(n)
B. O(log n)
C. O(n log n)
D. O(1)
Answer: B
Explanation: Number of cells used is logarithmic in input size.
5. If a TM solves a problem using only a fixed number of symbols regardless of input size, what is its space complexity?
A. O(n)
B. O(log n)
C. O(1)
D. O(n²)
Answer: C
Explanation: Fixed usage = constant space.
6. What is the worst-case space complexity of a TM that marks all 1s in a binary string using a separate work tape?
A. O(1)
B. O(log n)
C. O(n)
D. O(n²)
Answer: C
Explanation: Every 1 may be marked once. Even if a new tape is used, marking n symbols = O(n) space.
Thank you