Warning, this is the 10,000 foot view of this topic.
An algorithm A is polynomial if the timing function TA(n) ∈ O(nk), k constant.
We define the set of problems P to be the problems for which a polynomial time algorithm exists to solve the problem for all input.
Problem Z ∈ P if there exists an algorithm Az such that AZ ∈ O(nk) and for all input i, s= A(i), is a solution to Z for i.
An algorithm V(i,c) verifies a solution c (or certificate) for an input i and a problem Z
a = V(i,c)
If a = true, then c is a solution to Z for input i.
If a = false, then c is not a solution to Z for the input i.
For Sorting, i = (3, 6, 2, 1) , c= (1, 2, 3, 6)
VERIFY_SORT(I, C)
S ← SORT(I)
if S = C then
return true
else
return false
We define the set of problems NP to be the problems for which a polynomial time algorithms exists which can verify any solution to the problem.
Problem Z ∈ NP if there exists VZ(i,c) such that VZ ∈ O(nk) for constant k and Vz verifies Z.
CONVEX_HULL ∈ NP
VERIFY_CONVEX_HULL(S,C)
// remember, S is the set of points, and C is points supposedly on the hull.
C' = GRAHAM_SCAN(S)
C' = SORT(C')
C = SORT(C)
return C = C'
CLAIM: P∈ NP
A verification algorithm is an example of a decision algorithm.
A decision problem is a problem which takes an input and returns true if the input satisfies a criteria and false if it does not.
Given a circuit C, with n inputs, is there a set of inputs such that the circuit will produce a true. (CIRCUIT_SAT), review this problem.
We deal with many optimization problems, or problems which ask us for the best possible answer.
Given a complete weighted graph G = (V,E), and a starting vertex vs∈ V find the lowest cost path from vs visiting all other v∈V and only traversing an edge once that returns to vs (TSP)
In general, we can create a decision problem that is no harder, and possibly easier than a given optimization problem.
SHORTEST_PATH: given a graph G=(V,E), and a∈V, b∈V, find the shortest path from a to b.
PATH: Given a graph G, a and b as above, and a cost c, is the cost from a to b equal to c?
If we can show that the decision problem is hard, then the optimization problem is at least as hard.
A reduction
If A and B are decision problems.
α and β are inputs to these problems.
If the result rA is the result for A on α
If the result rB is the result for B on β
Algorithm R(α) → β is a reduction from
A to B if rA = rB for all α
written A ≤ B
If R ∈ P then R is a polynomial time reduction.
written A ≤P B
This is a way to say that we can solve A by transforming the input to an input for B and solving B.
We saw a polynomial time reduction from sorting to convex hull.
A problem A ∈ NPC (the set NP-Complete) if
A ∈ NP
for all problems S ∈ NP , S ≤PA
So NPC ∈ NP
But an open question: Is NPC ∈ P? (or does P = NP?)
Showing a problem is in NPC
Show it is in NP
IE Show that there exists an algorithm in P which will verify a solution to the problem.
Reduce all problems in NP to it in polynomial time.
The second step would be easier if we had a problem in NPC to start with,
Then we could reduce that problem to our problem.
And by the transitive property, all other problems in NP would be reduced to our problem.