0% found this document useful (0 votes)
8 views11 pages

Space Compl

The document discusses the concept of space complexity in Turing Machines, defining it as the maximum number of tape cells used during computation on an input of size n. It highlights the importance of space complexity in various computational contexts and outlines key space complexity classes such as L, NL, PSPACE, and EXPSPACE. Additionally, it provides examples and multiple-choice questions to illustrate the principles of space complexity.

Uploaded by

sourish22csu169
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views11 pages

Space Compl

The document discusses the concept of space complexity in Turing Machines, defining it as the maximum number of tape cells used during computation on an input of size n. It highlights the importance of space complexity in various computational contexts and outlines key space complexity classes such as L, NL, PSPACE, and EXPSPACE. Additionally, it provides examples and multiple-choice questions to illustrate the principles of space complexity.

Uploaded by

sourish22csu169
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Space Complexity Of Turing Machine

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

L Logarithmic Space O(log n) Deterministic

NL Nondeterministic Log Space O(log n) Non-deterministic

PSPACE Polynomial Space O(n^k), for constant k Deterministic/ND

NPSPACE Nondeterministic PSPACE O(n^k), for constant k Non-deterministic

EXPSPACE Exponential Space O(2^{n^k}), for constant k Deterministic/ND


Formal Defination

Let M be a Turing Machine and let w be an input string of length n,


The space complexity of M is a function S(n) such that for every input w with |w| = n, M uses at
most S(n) tape cells during its computation on w.

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?

Reading input 0110 ❌ Not counted Input tape is read-only

Overwriting
symbols
❌ Not counted Replaces input in-
place (0→x, 1→y)

Moving head ❌ Not counted Head movement does


not use memory

Internal state (A, B,


C)
❌ Not counted TM state is finite
(stored in control unit)

Using new tape


cells
❌ None used The TM never writes
outside input

Space Complexity S(n)=O(1)


Now here’s the core idea: We ask:
“How many extra tape cells are used during the ​
computation, besides the input itself?”
Examples :-
STEP-BY-STEP WORKING OF THE TM
Start at the first unmarked 0, mark it as X.

L={0n1n∣n≥1} Go right to find the first unmarked 1, mark it as Y.


Return to the left to find the next 0.
Repeat until all 0s and 1s are marked.
Accept if:
No unmarked 0s or 1s are left.
Tape head reaches a blank after only Xs and Ys.
This TM does in-place processing, meaning it overwrites 0s
with X and 1s with Y, rather than using extra memory.

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?

A. Number of transitions taken

B. Number of states used

C. Maximum number of tape cells used

D. Length of the input string

Answer: C

Explanation: Space complexity is the maximum number of tape cells a Turing Machine scans or uses (writes to) during computation.

2. Which of the following is NOT counted in space complexity?

A. Input symbols on the input tape

B. Symbols written on work tape

C. Blank cells used during computation

D. Symbols rewritten in-place on the tape

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

You might also like