Beruflich Dokumente
Kultur Dokumente
Definition 1 We say an algorithm solves a problem in polynomial time if its worst case
time efficiency belongs to O(p(n)) where p(n) is a polynomial of the problems input size
n. Remember when we say O(x) we are giving an upper bound and clearly the function
f(n) = log2n is less than the function g(n) = n3. Problems that can be solved in polynomial
time are said to be tractable and those that cannot be solved in polynomial time are
intractable.
A refresher from the beginning of the course in the following table
n
10
100
1,000
10,000
100,000
log2n
3.3
6.6
10
13
17
n
10
100
1,000
10,000
100,000
n log2n
33
660
10,000
130,000
1,700,000
n2
100
10,000
1,000,000
100,000,000
10,000,000,000
2n
1000
1.3x1030
n!
3.6x10
9.3x10157
We can now consider program P as an input to itself and use the output of algorithm A for
pair (P,P) to construct the program Q as follows:
Q(P)= halts, if A(P,P)=0, i.e., if program P does not halt in input P;
does not halt, if A(P,P) = 1, i.e., if program P halts in input P.
P = NP?
Definition 5 A decision problem D1 is said to be polynomially reducible to a decision
problem D2 if there exists a function t that transforms instances of D1 to instances of D2
such that
1. t maps all yes instances of D1 to yes instances of D2 and all no instances in D1 to
no instances of D2;
2. t is computable by a polynomial time algorithm.
This says that if D1 is polynomially reducible to some problem D2 that can be solved in
polynomial time, the D1 can also be solved in polynomial time.
Definition 6 A decision problem D is said to be NP-complete if
1. it belongs to the class NP, and
2. every problem in NP is polynomially reducible to D.
Now assuming that we already know that the Traveling Salesperson Problem to be NPcomplete we will show that the Hamiltonian Circuit Problem also NP-Complete.
Traveling Salesperson Find the shortest tour through n cities with known positive
integer distances between them.
Hamiltonian Circuit Determine whether a given graph has a Hamiltonian circuit (a
path that starts and ends at the same vertex and passes through all the other vertices
exactly once)
To do this we need to show that Hamiltonian Circuit problem is polynomially reducible
to the decision version of Traveling Salesperson. The latter can be stated as the problem
to determine whether there exists a Hamiltonian circuit in a given complete graph with
positive integer weights whose length is not greater than a given positive integer m. We
can map a graph G of a given instance of the Hamiltonian circuit problem to a complete
weighted graph G representing an instance of the traveling salesperson problem by
assigning 1 as the weight to each edge in G and adding an edge with weight 2 between
any pair of non-adjacent vertices in G. As an upper bound m in the Hamiltonian circuit
length, we make m = n, where n is the number of vertices in G (and G). Obviously this
transformation can be done in polynomial time.
Let G be a yes instance of the Hamiltonian Circuit problem. Then G has a Hamiltonian
circuit, and its image G will have length n, making the image a yes instance of the
decision traveling salesperson problem. Conversely, if we have a Hamiltonian circuit of
length not larger than n in G, then its length must be exactly n (why?) and hence a circuit
must be made up of edges present in G, making the inverse image a yes instance of the
traveling salesperson be a yes instance of the Hamiltonian circuit problem. This
completes the proof.