随机算法 (Fall 2011)/Complexity Classes

From EtoneWiki
Jump to: navigation, search

Upper bounds, lower bounds

Bounds are just inequalities (in a general sense, e.g. asymptotic inequalities). An inequality

is read " is a lower bound of " or equivalently " is an upper bound of ".

In Computer Science, when talking about upper or lower bounds, people really mean the upper or lower bounds of complexities.

In this lecture, we are focused on the time complexity, although there are other complexity measures in various computational models (e.g. space complexity, communication complexity, query complexity).

The complexity is represented as a function of , where is the length of the input.

There are two kinds of complexities:

Complexity of algorithms
For an algorithm , the (worst-case) time complexity of is the maximum running time over all inputs of length .
Complexity of problems
For a computational problem, its time complexity is the time complexity of the optimal algorithm which solves the problem.

The complexity of an algorithm tells how good the algorithm is, yet the complexity of a problems tells how hard the problem is. While the former is what we care mostly about in practice, the later is more about the fundamental truths of computation.

In Theoretical Computer Science, when talking about upper or lower bounds, people usually refer to the bounds of the complexities of problems, rather than those of algorithms. Therefore, an upper bound means an algorithm; and a lower bound means bad news such as impossibility results.

Today's lecture is devoted to lower bounds, i.e. the necessary prices which have to paid by any algorithms which solve the given problems. Speaking of necessary prices, we have to be specific about the model, the mathematical rules which stipulate what is problem and what is algorithm.

Decision problems

Computational problems are functions mapping inputs to outputs. Sometimes, an input is called an instance of the problem and an output is called a solution to that instance. The theory of complexity deals almost exclusively with decision problems, the computational problems with yes-or-no answers.

For a decision problem , its positive instances are the inputs with "yes" answers. A decision problem can be equivalently represented as the set of all positive instances, denoted . We call a formal language (not entirely the same thing as the c language). The task of computing is equivalent to that of determining whether . Therefore the two formulations of "decision problems" and "formal languages" can be interchangeably used.

Turing Machine

In order to study complexities, which deal with the limits of computations, we have to be clear about what computation is, that is, modeling computations.

This work was done by Alan Turing in 1937. The model is now referred by the name Turing machine.

Complexity Classes

Problems are organized into classes according to their complexity in respective computational models. There are nearly 500 classes collected by the Complexity Zoo.

P, NP

A deterministic algorithm is polynomial time if its running time is within a polynomial of on any input of length .

Definition (P)
The class P is the class of decision problems that can be computed by polynomial time algorithms.

We now introduce the infamous NP class.

Definition (NP)
The class NP consists of all decision problems that have a polynomial time algorithm such that for any input ,
if and only if , , where the size of is within polynomial of the size of

Informally, NP is the class of decision problems that the "yes" instances can be verified in polynomial time. The string in the definition is called a certificate or a witness. Provided a polynomial size certificate, the algorithm verifies (instead of computing) the for any positive instance in polynomial time.

Example
Both the problems of deciding whether an input array is sorted and deciding whether an input graph has Hamiltonian cycles are in NP. For the former one, the input array itself is a certificate. And for the later one, a Hamiltonian cycle in the graph is a certificate (given a cycle, it is easy to verify whether it is Hamiltonian).

This definition is one of the equivalent definitions of the NP class. Another definition (also a classic one) is that NP is the class of decision problems that can be computed by polynomial time nondeterministic algorithms.

Common misuses of the terminology:

  • "This algorithm is NP." --- NP is a class of decision problems, not algorithms.
  • "This problem is a NP problem, so it must be very hard." --- By definition, a problem is in NP if its positive instances are poly-time verifiable, which implies nothing about the hardness. You probably means the problem is NP-hard.
  • "NP problems are the hardest problems." --- There are infinitely many harder problems outside NP. Actually, according to a widely believed conjecture, there are infinitely many classes of problems which are harder than NP (see [1]).

Note that unlike P, the definition of NP is asymmetric. It only requires the positive instances (the that ) to be poly-time verifiable, but does not say anything about the negative instances. The class for that case is co-NP.

Definition (co-NP)
The class co-NP consists of all decision problems that have a polynomial time algorithm such that for any input ,
if and only if , , where the size of is within polynomial of the size of

Clearly, P NP co-NP. Does P = NP co-NP? It is an important open problem in the complexity theory which is closely related to our understanding of the relation between NP and P.

ZPP, RP, BPP

Now we proceeds to define complexity classes of the problems that is efficiently computable by the randomized algorithms, i.e. the randomized analogs of P.

In the last class we learned that there are two types of randomized algorithms: Monte Carlo algorithms (randomized algorithms with erros) and Las Vegas algorithms (randomized algorithms with random running time but with no erros). For Monte Carlo algorithms, there are two types of errors: one-sided errors where the algorithm errs only for positive instances, and two-sided errors where there are both false positives and false negatives. Therefore, there are three cases to deal with:

  1. Las Vegas algorithms, the corresponding class is ZPP (for Zero-error Probabilistic Polynomial time).
  2. Monte Carlo algorithms with one-sided error, the corresponding class is RP (for Randomized Polynomial time).
  3. Monte Carlo algorithms with two-sided error, the corresponding class is BPP (for Bounded-error Probabilistic Polynomial time).

We first introduce the class ZPP of the problems which can be solved by polynomial time Las Vegas algorithms. For Las Vegas algorithms, the running time is a random variable, therefore we actually refer to the Las Vegas algorithms whose expected running time is within a polynomial of for any input of size , where the expectation is taken over the internal randomness (coin flippings) of the algorithm.

Definition (ZPP)
The class ZPP consists of all decision problems that have a randomized algorithm running in expected polynomial time for any input such that for any input , .

Next we define the class RP of the problems which can be solved by polynomial time Monte Carlo algorithms with one-sided error.

Definition (RP)
The class RP consists of all decision problems that have a randomized algorithm running in worst-case polynomial time such that for any input ,
  • if , then ;
  • if , then .
Remark
The choice of the error probability is arbitrary. In fact, replacing the 1/2 with any constant will not change the definition of RP.
Example
Define the decision version of the minimum cut problem as follows. For a graph , if and only if there exists any cut of size smaller than , where is an arbitrary parameter. The problem can be solved probabilistically by Karger's min-cut algorithm in polynomial time. The error is one-sided, because if there does not exists any cut of size smaller than , then obviously the algorithm cannot find any. Therefore RP.

Like NP, the class RP is also asymmetrically defined, which hints us to define the co-RP class.

Definition (co-RP)
The class co-RP consists of all decision problems that have a randomized algorithm running in worst-case polynomial time such that for any input ,
  • if , then ;
  • if , then .

We then define the class BPP of the problems which can be solved by polynomial time Monte Carlo algorithms with two-sided error.

Definition (BPP)
The class BPP consists of all decision problems that have a randomized algorithm running in worst-case polynomial time such that for any input ,
  • if , then ;
  • if , then .
Remark
Replacing the error probability from to , or any constant will not change the definition of the BPP class.



What is known (you can even prove by yourself):

  • RP, BPP, ZPP all contain P
  • RP NP
  • ZPP = RPco-RP;
  • RP BPP;
  • co-RP BPP.

Open problem:

  • BPP vs P (the second most important open problem in the complexity theory to the NP vs P).