Ch.11
P, NP and Decision Problems
Continued


Figure 11.1: Commonly believed relationship between P and NP

We know about P. Suppose L has a deterministic polynomial time algorithm. Then L P.

Is L NP?

Sure. We could even put in a choice statement and never use it.

L P L NP.

Running time for algorithms

Polynomial
Exponential
search 0/1 knapsack
shortest paths traveling salesperson
spanning trees scheduling
... ...
good times - leave alone scope for improvement

Deterministic algorithms:

Nondeterministic algorithms:

Recall:

If x A then there exists a choice for j which will result in success

If x A no choice will result in success.

From the way a nondeterministic computation is defined, it follows that the number 0 can be output iff there is no j such that x = A[j]

If the number of alternatives for choice is finite then we can convert the nondeterministic alg. to a deterministic alg.

It is possible to construct a nondeterministic algorithm for which many different choice sequences lead to successful completions. NSort (Algorithm 11.2) and NPath illustrate.

Guess answer and verify ( not completely magic :-), we still need to check/define what problem we are solving)

Given a graph G with edge costs, does there exist a path from s to t of cost < M.

Time complexity of non-deterministic algorithms:

Choice statement takes 0(1)

Optimization vs decision problems

Decision : feasible solution (yes/no answer)

Optimization : feasible solution which optimizes objective function

Remember the decision algorithm for DHC:

If |V| = n then n! choices, for non-deterministically, each particular choice O(|E|) (to check).

Clique

A maximul complete subgraph of a graph G = (V, E) is a clique.

choices (subcliques of size k) (remember (pg 10) this is equal to n!/ k!(n - k)! ) (see also page 378 of text) ; for each particular choice O(k)

However, note that optimizing criteria can be built into definition of feasibility

Clique

A clique is a maximal complete subgraph of a graph G=(V,E).

size of clique = number of nodes in clique

The max clique problem is an optimization problem to determine the clique of maximum size

Optimization : find size of max clique in G    --    opt_clique(G)

Decision : does G contain a clique of size at least k    --    dec_clique(G,k)

Relation between opt_clique and dec_clique:

T(dec_clique) = f(n)
T(opt_clique) < n * f (n)

Two problems L1 and L2 are said to be polynomially equivalent iff L1 L2 and L2 L1

True for deterministic and nondeterministic algorithms.

Can we write dec_clique using opt_clique (try before looking)

T(opt_clique) = g(n)
T(dec_clique) = g(n)

Hence, dec_clique and opt_clique polynomially equivalent

Shortest path from s to t in G.

Decision: does there exist a path from s to t in G of cost < M

Optimization: find the length of the shortest path in G from s to t.

Assume : all costs are integers

if T(dec_path) = f(|input|) (see page 244 for how the representation affects the time)
then T(opt_path) = (|V|-1) * f(|input|)

|input| = adjacency matrix (list) + space to store costs

G = (V,E) , | V | = n, | E | = m

c = max cost of any edge

|input| = n2 + mlog c    bits

T (dec-path) = f (n2 + mlog c)

T (opt-path) = (n-1) * c * f(n2 + mlog c)

T (opt-path) not within a polynomial factor of T(dec-path).

Exercise: can you write opt-path in terms of dec-path such that T(opt-path) < p (|input|) * T (dec-path)? more

Satisfiability

boolean variables: x1, x2, . . ., xn     xi {0,1}

a literal is either a variable or its negation (denote here ¯x¯i): x1, ¯x¯1, x2, ¯x¯2, . . ., xn, ¯x¯n,

Boolean formula composed of literals, (and) , V (or) .

(x1 V ¯x¯2 V x4) (x2 V ¯x¯3 V ¯x¯4) (¯x¯2 V x4 V ¯x¯5)

(example: (T, F, F, ?, ?) works)

Conjunctive Normal Form CNF:       clause: literals, V        with        clauses anded together

as opposed to Disjunctive Normal Form DNF

Satisfiability: given a collecton of variables x1, . . ., xn and a set of clauses ci, 1 < i < m, is there a truth assignment (true/false) for xi's such that c1 c2 . . . cn= true

(Actually, the satisfiability problem is to determine whether a formula is true for some assignment. CNF-Satisfiability is the satisfiability problem for CNF formulas.)

non-deterministic alg.

|input| = O(m,n)

T (nEval) = O(m,n)

deterministic algorithm:

T (dEval) = O(2n mn)

P vs NP : decision problems

P = set of all decision problems which can be solved by deterministic algorithms in polynomial time

NP = set of all decision problems which can be solved by nondeterministic algorithms in polynomial time

P NP      :      just add dummy choice statements.

P NP      (proper subset?)      P =? NP      unresolved (can't prove it is, can't prove it isn't)

Identify 'toughest' problems in NP.

NP - complete NP

L NP-complete      =

  1. If L can be solved in deterministic polynomial time then every problem in NP can be solved in deterministic polynomial time. (if L P, then P = NP)
  2. If it can be shown that L cannot be solved by a deterministic polynomial time algorithm then P != NP (if L P then P NP)

There exist problems in NP not contained in NP-complete

Figure 11.2 Commonly believed P, NP, NP-Complete and NP-hard

Cook's Theorem

Cook's Theorem: Satisfiability is in P iff P = NP

Cook's theorem forms the basis for identifying problems which are NP-complete.

Why this is so important?

So, first a reminder on reductions

L1 reduces to L2 if we can solve L1 in deterministic polynomial time using a deterministic polynomial time algorithm for L2. (Definition 11.4 of text)

(L1 L2)
For every instance I1 L1, there exists an instance I2 L2 such that solution for I1 can be obtained from the solution for I2 in deterministic polynomial time.

Furthermore, I2 can be produced from I1 in det. poly. time

T(DET_L1) =T(DET_L2) + Poly

Ex:

L1 L2

"reduces" is transitive

Definitions:

  1. A problem L is NP-hard if and only if satisfiability reduces to L (satisfiability L).

  2. A problem is NP-complete if and only if L is NP-hard and L NP.

Note that all NP-Complete are NP-Hard, but not all NP-Hard are NP-Complete.

NP-Complete NP-Hard

From text: (page 506)

OK, think about this. NP-Hard is "harder" than NP-complete because NP-Complete must be NP-Hard and be in NP. That is, there is an NP algorithm for NP-Complete, but either there is not an NP algorithm or the problem is not a decision problem for NP-hard.

Given L1 NP-Hard.       Show L1 L2            L2 NP-Hard

IF you could also show that L2 has an NP algorithm, then it would be NP-Complete. If I cannot, the best I can say is that it is NP-Hard
Also from the text: