Professional Documents
Culture Documents
Is A ∈ T IM E(n2 )?
Is A ∈ T IM E(n log n)?
Is A ∈ T IM E(n)?
Could we potentially place A in a smaller complexity class if we consider other computational
models?
Theorem 1 If t(n) ≥ n, then every t(n) time multitape Turing machine has an equivalent O(t2 (n))
time single-tape turing machine.
Theorem 2 If t(n) ≥ n, then every t(n) time RAM machine has an equivalent O(t3 (n)) time
multi-tape turing machine.
[
P = T IM E(nk )
k
Equivalent Definition of NP
NP = {L|L has a polynomial time verifier }.
A polynomial time verifier for a language A is an algorithm, V , where A = {w|V acepts < w, c >
for some string c}.
Example 2 Let RELP RIM E = {< x, y > | gcd(x, y) = 1}. Is RELP RIM E ∈ N P ? Is
RELP RIM E ∈ P ?
M = “On Input < G, s, t > where G is a directed graph with nodes s and t.
1. Place a mark on node s.
2. While there exists an unmarked node do
3. Search for all edges (a, b) where a is marked and b unmarked, and mark such b.
4. If t is marked, accept; otherwise, reject.
To show an algorithm runs in polynomial, one must show that each step is executed only a poly-
nomial number of steps as well as each steps executes in polynomial time.
Example 5 V ALU E = {< φ, x > | φ(x) where φ is a boolean formula and x an assignment of
variables }. Is V ALU E ∈ P ?
Example 6 RAT ION ALROOT = {< p > | ∃q ∈ Q such that p(q) = 0 where p(x) = a0 + a1 x +
. . . + ak xk is a polynomial of degree k where ∀ i = 1 . . . k, ai ∈ ℵ.
Is RAT ION ALROOT ∈ P ?
1. Nondeterministically select q ∈ Q.
2. Evaluate p(q).
3. If p(q) = 0, accept; otherwise, reject.”
Does this run in polynomial time? Cearly, to evaulate p(q) is polynomial in the length of q since
multipication can be computed in polynomial time. How big is q though? From the Rational Root
Theorem in algebra, any rational root, x, of p(x) = 0 is of the form x = st where s|a0 and t|ak .
Since |a0 | = log(a0 ) < n and |ak | = log(ak ) < n, |q| = O(n). Thus, step 1 and 2 can be computed
in polynomial steps.
Example
P 7 Let SU BSET SU M = {< S, t > | ∃{y1 , y2 , . . . , yn } = Y ⊆ S = {s1 , s2 , . . . , sn } such
that i yi = t}
Construct a nondeterministic polynomial time Turing machine, M , as follows:
Relations:
P ⊆ N P ⊆ EXP T IM E ⊆ N EXP T IM E
Definition 7 (Space Complexity Classes)
SP ACE(t(n)) = {L | ∃ DTM M which decides L in space O(t(n))}.
[
P SP ACE = SP ACE(nk )
k
[
N P SP ACE = N SP ACE(nk )
k
GS019 - Lecture 1 on Complexity Theory Jarod Alper (jalper)
L = SP ACE(log n)
N L = N SP ACE(log n)
How can our definition of a turing machine use only logarithmic space since the input tape uses
linear space? We introduce a new turing machine with two tapes: a read-only input tape and a
read/write tape.
Example 8 P AT H ∈ N L
Proof: A deterministic turing machine that decides membership in O(f (n)) steps can use at most
O(f (n)) space since one TM step requires can only write to one memory cell. 2
Proof: Define a configuration as a snap shot of a turing machine including the position of the heads,
the state of the control unit, and the contents of all cells on tape. If our turing machine is restricted
to O(f (n)) space, the work tape head can be in only O(f (n)) locations and the input tape head
can be in only O(n). The control unit can be in any of c positions were c is a constant representing
the number of states in the fsm. If we have k characters that can be written to a cell, then there
are O(kf (n) ) possibilities for the content of the tape. Thus, there are O(c n f (n) kf (n) ) = O(kf (n) )
configurations. If the turing machine is to halt, there will be no duplicate configuration and thus
it must run in O(kf (n) )2.
Corollary 1 L ⊆ P
Corollary 2 P ⊆ P SP ACE
Definition 9 (coC) The complement of a complexity class of decision problems C, denoted coC,
is the set of decision problems that are complemnt of decision problems of C.
Is NP = coNP?
T
Theorem 7 N P coN P 6= {}
T
Proof: Let P RIM ALIT Y = {< n > |n is prime}. We show P RIM ALIT Y ∈ N P coN P .
not quite done.
Lemma 1 An integer p > 2 is prime iff there is an integer 1 < r < p such that r p−1 ≡ 1(modp)
p−1
and ∀q such that q|p − 1, r q 6 ≡1(modp).