34.1 Polynomial Time

Document last modified: 

Solvable problems

Polynomial time algorithms generally regarded as tractable solutions to problems.

  1. Lower-order polynomial time algorithms most common.Θ(n100) superpolynomial time but intractable, often the case that a lower-order polynomial time algorithm will be discovered.
  2. Polynomial time solution in one computing model can often be solved in polynomial time in another model. Increasing the number of processors does not significantly change the order of the solution.
  3. A solution using two polynomial time algorithms, where the output of one is the input of the other, is still polynomial time.

Example: Closure property under addition, multiplication and composition. Total time(A & B) = Time(A) + Time(B)

 

Abstract Problems

abstract problem Q - a binary relation that associates each instance with a solution

Let set I be a set of problem instances

Let set S be a set of problem solutions

Then Q is a binary relation on I and S, Q | I x S

I x S can have empty or non-unique solutions

Example

A Path problem instance is the input: a triple (G, u, v), where G is a directed graph and u and v are vertices in the graph.

At right: G =( V, E ), u=s, v=x.

 

Path's I - is the set of all problem instances of the Path type.  I = {i1, i2, ... }, where each ij is of the form (G, u, v).

(G,s,x) represents one instance of I.

 

Path's S - is the set of all Path solutions.  S = {s1, s2, ... }, where each sj is of the form <v1, v2,  ..., sn >, a sequence of vertices in the graph, or <|> if no path exists.

For the graph, one instance of S is the path <s,y,z,x>.

For the graph, one instance not of S is the path <x, s>.

 

The Path Abstract Problem (PAP):

  • Is a relation PAP | I x S such that members of the relation are tuples of the form (ij, sk) and appear in the relation only when solution sk is a solution to problem instance ij.
    • Example: ij=(G, s, x), sk=<s,y,z,x> so (ij, sk) ∈ PAP, that is an (instance, solution) tuple.
  • (ij, sk) does not appear in PAP if sk is not a solution to problem instance ij 
  •  ij may appear in PAP more than once since there may be more than one solution to problem instance ij

Question: Give another (ij, sk) ∈ PAP.

abstract decision problem D - a binary relation that associates each instance with a yes/no solution

Let I be a set of decision problem instances

Let S be the set {0, 1}

Then D is a binary relation on I and S, D | I X S and every tuple in D has the form (ij, sk) with sk = either 0 or 1

Example

The Path abstract decision problem is a four-tuple (G, u, v, k), where G is a graph and u and v are vertices in the graph, and k is the upper limit on the number of edges in the path from u to v.

Path's I - is the set of all problem instances of the Path type.  I = {i1, i2, ... }, where each ij is of the form (G, u, v, k

Path's S - is the set of all Path solutions.  S = {0, 1}

The Path Abstract Decision Problem (PADP):

  • Is a relation PADP | I X S such that members of the relation are tuples of the form (ij, sk) and ∀j ijI then (ij, 0) ∈ PADP or (ij, 1) ∈ PADP, where sk = 0 if there does not exist a path from u to v of at most k edges and sk = 1 if a path does exists with at most k edges.

    Examples:

    • ij=(G, s, z, 20), sk=1
    • ij=(G, s, z, 1), sk=0

Summary

To develop a method for showing a problem is NP-complete, we need a general representation of problems (abstract) and that have a yes/no answer (decision).

 

Encodings

Example

Given the graph G, provide an encoding for a PATH decision problem xi = (G, u, v, k), where:

G is the graph,

u is the source vertex,

v is the target vertex,

k is an integer specifying the maximum allowable length of a path from u to v.

G = (V, E)
V = {r, s, t, u, v, w, x, y}
E = {(r, s) (r, v) (s, w) (w, t) (w, x) (t, u) (t, x) (u, y) (u, x)}

x1 = (G, r, y, 5) = ((V, E), r, y, 5)

     = (({r, s, t, u, v, w, x, y},
           {(r, s) (r, v) (s, w) (w, t) (w, x) (t, u) (t, x) (u, y) (u, x)} ),
              r, y, 5) =

                 (          (          {         r            ,          

e(x1) = 0101000 0101000 1111011 1110010 0101100
s           ,           t          ,             u         ,
1110011 0101100 1110100 0101100 1110101 0101100
1110110 0101100 1110111 1110111 0101100 1111000
0101100 1111001 1111101 0101100 1111011 0101000
1110010 0101100 1110011 0101001 0101000 1110010
0101100 1110110 0101001 0101000 1110011 0101100
1110111 0101001 0101000 1110111 0101100 1110100
0101001 0101000 1110111 0101100 1111000 0101001
0101000 1110100 0101100 1110101 0101001 0101000
1110100 0101100 1111000 0101001 0101000 1110101
0101100 1111001 0101001 0101000 1110101 0101100
1111000 0101001 1111101 0101001 0101100 1110010
0101100 1111001 0101100 0110101 0101001

   ,         y           ,           5          )

Use ASCII for the vertex labels, and the special symbols:

symbol ASCII 7-bit
r 114 1110010
s 115 1110011
t 116 1110100
u 117 1110101
v 118 1110110
w 119 1110111
x 120 1111000
y 121 1111001
{ 123 1111011
} 125 1111101
( 40 0101000
) 41 0101001
, 44 0101100
5 53 0110101

 

Formal Language Framework Executive Summary
  • Representation for decision problem D instances in language DL (e.g. as some encoding)
  • Show that DL can be translated in polynomial time to language for NP-complete decision problem such as CSATL
  • Implies D is NP-complete

 

Formal Language Framework

Decision problem Q

*, the set of problem instances, that Q produce a 1 (yes)

Q as a language L over ∑ = {0, 1} where:

L = {x ∈ ∑* :  Q(x) = 1}

Says that L is the language over all instances for which decision problem Q produces 1 (yes).

Example:

The PATHL language for the PATH decision problem is then:

PATHL  = {<G, u, v, k> :

G=(V, E) is an undirected graph
u, v ∈ V
k ≥ 0 an integer and there exists a path from u to v in G consisting of at most k edges }

PATHL defines the set of instances for which the decision problem PATH produces 1 (yes).

Example:

<G, s, x, 3> is one instance of PATHL where:

V= {s,y,z,x}

E = {(s,x),(x,y),(y,x),(y,z),(s,y)}

G = (V,  E)

Question:

  •  Is <G, s, x, 1> one instance of PATHL?
  •  Is <G, s, z, 1> one instance of PATHL?

 

Relation Between Decision Problems and Algorithms

accepts - algorithm A accepts as input a string x ∈ {0, 1}* if A(x) produces 1 as output

rejects - algorithm A rejects as input a string x ∈ {0, 1}* if A(x) = 0 as output

accepted - for language L = {x ∈ {0, 1}* : A(x) = 1} then language L is said to be accepted by algorithm A, L is the set of strings A accepts.

decided - algorithm A decides language L if ∀x ∈ L, A(x) = 1 and ∀x ⊆ L, A(x) = 0

If ∀x ∈ L, A(x) = 1 and ∃x ⊆ L that A(x) fails to reject (e.g., runs forever) then A does not decide L.

Example: If the PATH decision problem loops infinitely on any instance not in the PATHL language, then the PATH decision problem does not decide the PATHL language.

accepted in polynomial time - algorithm A accepts language L in polynomial time if L is accepted by A and if ∃ k ≥ 0 such that ∀x ∈ L, A accepts x in O(nk) time.

decided in polynomial time - algorithm A decides language L in polynomial time if L is decided by A and if ∃ k ≥ 0 such that ∀x ∈ L, A correctly decides whether x ∈ L in O(nk) time.

Example of a language:

PATHL language for PATH decision problem:

PATHL = {<G, u, v, k>  :

G=(V, E) is an directed graph
u, v ∈ V
k ≥ 0 an integer and there exists a path from u to v in G consisting of at most k edges }

accepts - algorithm A accepts as input a string x if A(x) produces 1 as output

accepted - for language L, ∀x ∈ L, A(x) = 1 then language L is said to be accepted by algorithm A, L is the set of strings A accepts.

rejects - algorithm A rejects as input a string x if A(x) = 0 as output

decided - algorithm A decides language L if ∀x ∈ L, A(x) = 1 and ∀x ⊆ L, A(x) = 0

Example of an accepting algorithm:
  • The language PATHL for the PATH decision problem can be accepted in polynomial time by algorithm APATH.
  • APATH works as follows on instance (G, u, v):
    1. verifies that G correctly encodes an directed graph
    2. verifies that u and v are vertices in G
    3. uses Dykstra Algorithm to compute the shortest path from u to v in G
    4. compares the number of edges found in the shortest path to k
    5. If G correctly encodes an directed graph, and if the number of edges in the shortest path from u to v is less than or equal to k, then APATH outputs a 1 and halts, accepts instance. Otherwise APATH runs forever.
Example of a deciding algorithm:

APATH works the same as above, but if G correctly encodes a directed graph, and if the number of edges in the shortest path from u to v is less than or equal to k, then APATH outputs a 1 and halts, accepts. Otherwise APATH outputs a 0 and halts, rejects.

Question a

For the instance of PATHL:

V= {s,y,z,x}

E = {(s,x),(x,y),(y,x),(y,z),(s,y)}

G = (V,  E)

Would APATH <G, s, x, 2>

  • accept?
  • reject?
  • decide?

Question b

What about APATH <G, s, x, 4>

Complexity Classes