This presentation is an adaptation of material from Antoni Lozano and Conrado Martinez
Before we start: Questions on previous material?
Analysis of Algorithms studies the amount of resources that an algorithm needs to solve a problem.
Complexity Theory classifies problems according to the resources needed to solve them (with the best of the available algorithms)
“The cost of any sorting algorithm1 to sort n items in the worst-case is \Omega(n \log n)”
“Deciding whether a graph is k-colorable has the same difficulty (modulo a polynomial factor) of deciding whether it has a Hamiltonian cycle.”
Definition 1 (Decision Problem) A decision problem is a computational problem with output YES/NO (or 0/1).
Equivalently, a decision problem is one where one has to determine whether the input satisfies (or not) a certain property.
We will only consider classes of problems that can be solved with a certain amount of resources.
Example 1 The following are decision problems:
What could be an example of a computational problem which is not a decision problem?
The instances of the problem will belong to some set I of inputs:
Definition 2 (Size of the input) Given x\in I, the size of x, denoted |x| is the number of symbols (e.g., bits) of a standard (binary) encoding of x.
Let f: \mathbb N \to \mathbb N be a function
Definition 3 A decision problem B with input set I is decidable in time f if there exists an algorithm A:I\to\{0,1\} such that
A(x)=1 if and only if x is a positive instance of B.
The complexity class \mathsf{P} is polynomial time: a decision problem A is in \mathsf{P} if there exists a constant k such that A is decidable in time n^k. More formally,
\mathsf{P}=\bigcup_{k\in \mathbb N}\mathsf{TIME}(n^k)\ , where \mathsf{TIME}(f):= \text{all the decision problems decidable in time $f$}
The complexity class \mathsf{EXPTIME} is exponential time: a decision problem A is in \mathsf{EXPTIME} if there exists a constant k such that A is decidable in time 2^{n^k}. More formally,
\mathsf{EXPTIME}=\bigcup_{k\in \mathbb N}\mathsf{TIME}(2^{n^k})
The complexity class \mathsf{2\text{-}EXPTIME} is double-exponential time: a decision problem A is in \mathsf{2\text{-}EXPTIME} if there exists a constant k such that A is decidable in time 2^{2^{n^k}}. More formally,
\mathsf{2\text{-}EXPTIME}=\bigcup_{k\in \mathbb N}\mathsf{TIME}(2^{2^{n^k}})
\mathsf{P}\subsetneq \mathsf{EXPTIME}\subsetneq \mathsf{2\text{-}EXPTIME}
Seeing that \mathsf{P}\subseteq \mathsf{EXPTIME}\subseteq \mathsf{2\text{-}EXPTIME} is easy, what is difficult is to show that
\mathsf{P}\neq \mathsf{EXPTIME}
and that
\mathsf{EXPTIME}\neq \mathsf{2\text{-}EXPTIME}
This is done by diagonalization (beyond the scope of this course).1
In deterministic algorithms the computation path from the input to the output is unique. All algorithms seen so far are deterministic.
The execution of a deterministic algorithm A on a given input x starts at some state and is described by a finite path in the “graph of states” leading to some state where the output is either 0 or 1 and the computation ends.
That path is uniquely determined by x.
In a non-deterministic algorithm many distinct computational paths, forming a tree, are considered at once:
Non-deterministic algorithms are just like ordinary algorithms, but, given input x, they also can use the operation CHOOSE(y)
which returns a value between 0 and y, as long as y\leq x.
On each invocation to CHOOSE
the current computation path “forks” into y+ 1 branches, each one corresponding to one possible value returned by CHOOSE
.
Given a number n, is n composite? That is, is there a number j with 1 < j < n such that j divides n?
polynomial in the bitsize of the input but non-deterministic
Open question: Is \mathsf{FACTORING}\in \mathsf{P}?
Given a graph G and an integer k, is G k-colorable?
A decisional problem A with input set I is decidable in nondeterministic polynomial time iff there exist
for all x\in I, x is a positive case of A if and only if there exists a witness/certificate y\in O such that |y|\leq p(|x|) and V(x,y) = 1.
Definition 4 The set of all decision problems that can be decided in non-deterministic polynomial time is \mathsf{NP}.
\mathsf{P}\subseteq \mathsf{NP}\subseteq \mathsf{EXPTIME}
But we know \mathsf{P}\neq \mathsf{EXPTIME}, so for sure either \mathsf{P}\neq\mathsf{NP} or \mathsf{NP}\neq \mathsf{EXPTIME} (or both).
So what is the case? Is \mathsf{P}=\mathsf{NP} or \mathsf{P}\neq \mathsf{NP}?1
This is known as the \mathsf{P} vs \mathsf{NP} open problem and it is believed to be a very difficult mathematical open problem.2
Questions?