Algoritmu sarežģītība
14.lekcija
No sākuma atgādināsim tās definīcijas, kas tiek pieminētas iepriekšēja lekcijā:
VERTEX COVER (VC)
Instance: A graph G = (V, E) and a positive integer K<= |V|
Question: Is there a vertex cover of size K or less for G, that is a subset Vī V such that |V| <= K and for each edge (u,v) ļ E, at least one of u and V belogs to V
HAMILTON CIRCUIT (HC)
Instance: A graph G = (V, E)
Question: Does G contain a Hamiltonian circuit, that is an ordering < v1, v2, , vn > of the vertices of G, where n = |V| such that { vn, v1 } ļ E and { vi, vi+1 } ļ E for all i,
1 <= i <= n.
Tagad apskatīsim sekojošu teorēmu:
Teorēma: VC <= poly HC
Mums vajag katram virsotņu pārklājumam uzkonstruēt atbilstošu grafu, kurā norādīt Hamiltona ciklu.
Katrai šķautnei e = (u,v) dotajā grafā atbilst bloks.

Kur v un u ir virsotnes, kuras savieno šī šķautne. Šinī grafa virsotnes (u,e,1), (v,e,1), (u,e,6) un (v,e,6) ir saistītas ar ārpusi.
Mēs apstaigāsim šos blokus šādi:

Katrai virsotnei v dotajā grafā kaut kā ir sanumurētas šķautnes, kas ieiet (iziet) šajā virsotnē e1, e2, , ed . Tas nozēme, ka katra virsotne ir d blokos. Bloki ir savienoti un pedējais bloks ir savienots ar pirmo (skat. 4.zīm.). Bez šiem blokiem, jaunajā grafā ir vēl k virsotnes a1, a2, , ak, kuras sauc par selektora virsotnēm. Kur k ir no VC definīcijas (virsotņu skaits pārklājumā).
Ja dotajā grafā ir pārklājums ar izmēru k, tad a1, a2, , ak asociē ar virsotnēm pārklājumā (v1, v2, , v).
Šajā grafā (skat. 4.zīm.) eksistē Hamiltona cikls. Katru bloku mēs apstaigājam, kā ir uzradīts zīmējumos 1), 2), 3). Sākot no virsotnes a1, apstaigājot visus pirmas virsotnes blokus, mēs atgriežamies virsotnē a2 u tt. var apstaigāt visas virsotnes un atgriezties virsotnā a1.
4.zĻm.

Talāk tiek apskatīti dažādi NP-pilni uzdevumi visi ir poly reducējami viens uz otru:
MINIMUM COVER
Instance: Collection C of subsets of a finite set S, positive integer K<= Ė C Ė
Question: Does C contain ir cover for S of size K or less, i.e. a subset C '= C with
Ė C ' Ė <= K such that every element of S belongs to at least one member of C '
SUBSET SUM
Instance: Finite set A, size S(a) ļ Z+ for each a ļ A, positive integer B.
Question: Is there a subset A'<= A such that the sum of sizes of the elements in A' ie exactly B.
BIN PACKING
Instance: Finite set U of items, a size S(u) ļ Z+ for each uļ U a positive integer bin capacity, and a positive integer K.
Question: Is there a partition of U into disjoint sets u1,u2, , uk such that the sum of sizes of the items in each ui is B or less.
SHORTEST COMMON SUPERSEQUENCE
Instance: Finite alfabet å , finite set R of strings from å * and a positive integer K.
Question: Is there a string w ļ Å * with Ė w Ė <= K such that each string xļ R is a subsequence of w, i.e.
w = w0 x1w1 x2w2 xkwk, where each wi ļ Å * and x = x1x2 xk
SPARCE MATRIX COMPRESSION
Instance: An m“ n matrix A with aij ļ
{ 0,1} , 1<= i <= m, 1<= j <= n, and a positive integerk <= m*n
Question: Is there a sequence (b1,b2, ,bn+k) of integers b each satisfying 0<= bi <= m and a function.
S: {1, 2, , m}® {1, 2, , K} such that, for 1<= i <= m and 1 <= j <= n, the entry aij = 1 if and only if bS(i)+ j-1= I
STRING-TO STRING CORRECTION
Instance: Finite alphabet Å , two strings x,y ļ Å *, and a positive integer K
Question: Is there a way to derive the string y from the string x by a sequence of k or fewer operations of single symbol deletion or adjacent symbol interchange.