Advanced Algorithms and Complexity: The Complexity Class N P
Advanced Algorithms and Complexity: The Complexity Class N P
Lecture 2
The Complexity Class N P
August 6, 2018
1
Time-complexity of NTM: We say that a given NTM M runs in T (n)
time if for every input x ∈ {0, 1}∗ and every sequence of non deterministic
choices, M reached a halting state (either accepting or non-accepting) within
T(|x|) steps.
NTime(T (n)): For every function T : N → N and L ⊆ {0, 1}∗ we say that
L ∈ NTime(T (n)) if ∃ NTM M such that M accepts L and it runs in time
O(T (n)).
The time complexity class N P is defined as N P = ∪c∈N Ntime(nc ).
Example of NTM: Now we will generalize the DTM for Le = {0, 00, 10,
000, 010, 110, ...} into an NTM as follows:
δ(q0 , .) = {(q1 , ., R)}
δ(q1 , 0) = {(q1 , 0, R), (q3 , 0, R)}
((q3 , 0, R) is an incorrect guess. NTM will always ignore this choice for ac-
cepting inputs.)
δ(q1 , 1) = {(q1 , 1, R)}
δ(q1 , B) = {(q2 , B, L)}
δ(q2 , 0) = {(qh , 0, S)}
We can easily verify that this NTM accepts Le . Its time complexity is
O(n) =⇒ Le ∈ Ntime(T (n)) and also Le ∈ N P .
2
and a polynomial-time DTM M (called the verifier for L) such that for every
x ∈ {0, 1}∗ , x ∈ L ⇐⇒ ∃u ∈ {0, 1}p(|x|) such that M accepts (x, u).
If x ∈ L and u ∈ {0, 1}p(|x|) satisfy M accepts (x, u), then we call u a certifi-
cate for x (with respect to the language L and machine M ).
1. On input (Gn×n , k), append string of length n after the input by using
the first non-deterministic choice as writing 0, and the second non-
deterministic choice as writing 1.
3
set of size at least k.
If (Gn×n , k) ∈
/ INDSET then there does not exist any independent set of
size at least k. Then every possible encoding of u will not be able to make
the DTM accept the input ((Gn×n , k), u).
We can clearly see that the DTM runs in polynomial time, and that the
length of the certificate = |u| = n is also a polynomial =⇒ INDSET ∈ N P .
The two definitions of N P (using NTM N (x) and DTM D(x, u)) are equiv-
alent: