You are on page 1of 3

CS340: Theory of Computation

Lecture 33-34
Complexity Theory
Let M be a deterministic Turing machine that halts on all inputs, then the running time or
time complexity of the M is a function f : N Ñ N, where f pnq is the maximum number of steps
that M takes on an input of length n.

Asymptotic Upper Bound


Let f and g be functions, f, g : N Ñ R` . We say f pnq “ Opgpnqq if Dc, n0 P N s.t. @n ě n0 , f pnq ď
cgpnq.

When f pnq “ Opgpnqq, we say that gpnq is the asymptotic upper bound for f pnq.

Eg.: the TM algorithm for the language A “ t0k 1k | k ě 0u.


1. Scan through the tape and reject if 0 is found to the right of 1.
2. Repeat if both 0s and 1s remain on the tape.
Scan through the tape crossing off single 0 and a single 1.
3. If 0s still remain after all the 1s have been crossed off, or if 1s still remain after all the 0s
have been crossed off, reject. Otherwise, if neither 0s nor 1s remain on the tape, accept.
Running time: Opnq ` Opn2 q ` Opnq ” Opn2 q

Definition: Let t : N Ñ R` be a function. We define time complexity class T IM Eptpnqq


to be the collection of all languages that are decidable by the Optpnqq time Turing machine.
T IM Eptpnqq “ tL | D a Turing machine having a running time Opnq s.t. L “ LpM qu

For the example described above, consider the following


1. Scan across the tape and reject if a 0 is found to the right of a 1.
2. Repeat as long some 0s and some 1s remain on the tape
(a) Scan across the tape, checking whether the total number of 0s and 1s remaining is even
or odd. If it is odd, reject. Ů Ů
(b) Scan. Replace every other 0 with . Replace every other 1 with .
3. If no 0s or 1s remain, then accept.
Thus we can establish: A P T IM Epn logpnqq. We can also achieve linear time complexity for
the above problem as well.

Complexity Class P
ď
P “ T IM Epnk q
k

P is the class of language that are decidable in polynomial time on a deterministic single tape
TM.

Eg.: P AT H: given a directed graph G along with two modes u and v, determine if a path exists
from u to v. We can have: P AT H “ tG#u#v | G is a directed graph that has a path from u to vu.
P AT H P P .
2

Eg.: CF L membership “ tG#x | G is a CFG and x “ LpGqu. We also have, CF L membership P


P.

Complexity class NP
Consider the following problem:
Eg.: SAT “ tα | D a valuation v s.t. v ⊨ αu
HAM P AT H “ tG#s#t | G is a directed graph with Hamiltonian path from s to t u

A verifier and a Non-deterministic TM


A verifier for a language A is an algorithm V , where A “ tw | V accepts w#c for some string cu.
A polynomial time verifier runs in time polynomial in the length of w.

Non-deterministic Turing machine has a transition function like: δ “ Q ˆ Γ Ñ P pQ ˆ


Γ ˆ tL, Ruq.

As a corollary, N T IM Eptpnqq “ tL | D a non-deterministic TM M running in time tpnq s.t. L “ LpM qu


NP is the class of languages that have a polynomial time verifier.

P class of languages for which membership can be decided efficiently. N P is the class of
languages for which membership can be verified easily.
Theorem: For every non-deterministic TM, there is an equivalent deterministic TM.
The running time of a NTM is t : N Ñ R` if @x P Σ˚ .
If M halts in atmost qptp|x|qq steps, the the maximum number of steps M uses on any branch
of its computation on x is Optp|x|qq.

You might also like