Algorithms Complexity P vs NP
Algorithms and NP
G. Carl Evans
University of Illinois
Summer 2019
Algorithms and NP Algorithms Complexity P vs NP Review Algorithms
Model algorithm complexity in terms of how much the cost increases as the input/parameter size increases In characterizing algorithm computational complexity, we care about Large inputs Dominant terms √ 1 log n n n n log n n2 n3 2n 3n n!
Algorithms and NP Algorithms Complexity P vs NP Closest Pair
01 closestpair(p1,..., pn) : array of 2D points) 02 best1 = p1 03 best2 = p2 04 bestdist = dist(p1,p2) 05 for i = 1 to n 06 for j = 1 to n 07 newdist = dist(pi ,pj ) 08 if (i 6= j and newdist < bestdist) 09 best1 = pi 10 best2 = pj 11 bestdist = newdist 12 return (best1, best2)
Algorithms and NP Algorithms Complexity P vs NP Mergesort
01 merge(L1,L2: sorted lists of real numbers) 02 if (L1 is empty and L2 is empty) 03 return emptylist 04 else if (L2 is empty or head(L1) <= head(L2)) 05 return cons(head(L1),merge(rest(L1),L2)) 06 else 07 return cons(head(L2),merge(L1,rest(L2)))
01 mergesort(L = a1, a2,..., an: list of real numbers) 02 if (n = 1) then return L 03 else 04 m = bn/2c 05 L1 = (a1, a2,..., am) 06 L2 = (am+1, am+2,..., an) 07 return merge(mergesort(L1),mergesort(L2))
Algorithms and NP Algorithms Complexity P vs NP Find End
01 findend(A: array of numbers) 02 mylen = length(A) 03 if (mylen < 2) error 04 else if (A[0] = 0) error 05 else if (A[mylen-1] 6= 0) return mylen-1 06 else return findendrec(A,0,mylen-1)
11 findendrec(A, bottom, top: positive integers) 12 if (top = bottom+1) return bottom bottom+top 13 middle = floor( 2 ) 14 if (A[middle] = 0) 15 return findendrec(A, bottom, middle) 16 else 17 return findendrec(A, middle, top)
Algorithms and NP Algorithms Complexity P vs NP Fine Min
01 FindMin(a1,... an) : list of numbers) 02 if (n=1) return a1 03 else return min(a1,findmin(a2,... an))
Algorithms and NP Algorithms Complexity P vs NP Review Big O
f (n) is O(g(n)) if the dominant terms in f (n) are equivalent or dominated by the dominant terms in g(n) f (n) is Ω(g(n)) if the dominant terms in f (n) are equivalent or dominate the dominant terms in g(n) f (n) is Θ(g(n)) if the dominant terms in f (n) are equivalent the dominant terms in g(n)
Algorithms and NP Algorithms Complexity P vs NP Computational Complexity
ALL
AH
RE
R
PR
ELEMENTARY
NEEE P-Sel
NEEXP EEE
EEXP EESPACE
MIP_{EXP} EXPSPACE
IP_{EXP} PEXP EXPH
SEH NEXP^{NP} NEE
EXP^{NP} AM_{EXP}
NEXP/poly MA_{EXP} BPEE
EXP/poly NEXP BPEXP EE +EXP
EXP QRG ESPACE
RG Almost-PSPACE QPSPACE
PSPACE Coh
PL_{infty} CH
MP^{#P} AvgE
P^{PP} EH
PP/poly P^{#P[1]}
BP.PP MP
PH SF_4
Sigma_3P AmpMP
QMIP QMIP_{le} QMIP_{ne} SQG Delta_3P
BQP/qpoly MIP* QIP MIP RG[1] Sigma_2P BPP^{NP}
BQP/mpoly NE/poly XOR-MIP*[2,1] QMA(2) QIP[2] IP RP^{NP} frIP
Complexity Classes BQP/poly NP/poly QSZK QAM AM[polylog] compIP ZPP^{NP} QS_2P PP SF_3
(NP-cap-coNP)/poly BQP/qlog DQP CZK AM S_2P P^{QMA} A_0PP SF_2
P/poly BQP/mlog N.NISZK SZK QMA Delta_2P BPP_{path} APP Check
BPP//log BQP/log YQP NIQSZK NISZK_h QCMA SBP MA_E P^{NP[log^2]} AWPP C_=P
IC[log,poly] BPP/rlog BQP NE NISZK MA WAPP BPE P^{NP[log]} WPP
BPP/mlog HeurBPP YPP N.BPP PZK AmpP-BQP RPE BPQP UE BH ModP
Inherent Complexity NP/log BPP/log AVBPP FH TreeBQP ZPE BH_2 LWPP Mod_5P +P Mod_3P
Nearly-P NP/one P/log BPP E US RP^{PromiseUP} SPP NT*
AvgP NP RQP SUBEXP P^{FewP} NT
YP compNP RBQP ZQP QP Few EP
ZBQP RP EQP betaP QPLIN FewP UAP
QNC ZPP Q beta_2P UP
P-Close RNC HalfP NLINSPACE
P NLIN polyL
NC LIN SC
QCFL AL NC^2
+L/poly +SAC^1 L^{DET} AC^1
NL/poly +L SAC^1 PL CSL
L/poly C_=L 1NAuxPDA^p GCSL
NL SPL CFL BPL
LFew RL DCFL
FewL LogFew
FewUL FOLL
UL R_HL
QNC^1 L
TC^0/poly NC^1 PBP
QACC^0 TC^0 REG
PT_1 QAC^0 MAC^0 ACC^0 (k>=5)-PBP
PL_1 AC^0/poly AC^0[2] MAJORITY 4-PBP
SPARSE QNC_f^0 AC^0 3-PBP
TALLY QNC^0 SAC^0 +SAC^0 2-PBP
NC^0 PARITY
NONE https://www.math.ucdavis.edu/~greg/zoology/intro.html
Algorithms and NP Algorithms Complexity P vs NP P and NP
A problem is in the class P if a polynomial-time solution exists
A problem is in the class NP (non-deterministic polynomial time) if if a solution can be checked in polynomial time.
Algorithms and NP Algorithms Complexity P vs NP Examples 3-SAT
Boolean satisfiability: Determine if any assignment of n boolean variables can satisfy a set of logical expressions
3-SAT: The formula must be in CNF with exactly 3 literals per clause.
Algorithms and NP Algorithms Complexity P vs NP Examples Sorting
Given a array of integers can you sort the set.
Algorithms and NP Algorithms Complexity P vs NP Examples Graph Coloring
Determining if the graph is n-colorable
Determining if the graph is not (n+1)-colorable
Algorithms and NP Algorithms Complexity P vs NP CIRCUIT-SAT and Cook-Levin theorem
The circuit satisfiability problem (CIRCUIT-SAT) asks the question if there is a set of inputs to a boolean circuit such that the output is true.
The Cook-Levin theorem says that this problem is NP-complete. A problem is NP-complete if it is in NP and if there is a polynomial time solution to the problem P=NP
Algorithms and NP Algorithms Complexity P vs NP P = NP?
Conceptually this is the question “Is it easer to check a problem then to find the solution?” Yes P 6= NP No P = NP
Proof is worth $1,000,000 (Millennium Prize Problem)
Algorithms and NP Algorithms Complexity P vs NP How it all fits together
P NP NP-complete NP-Hard
Algorithms and NP Algorithms Complexity P vs NP Things to remember
Be able to analyze code for computational cost Tools: finding loops and recursive calls, using recursion trees Sometimes need to know inner-workings of a library to determine Be able to convert to big-O or big-Θ and be familiar with basic complexity terms Problems in NP can be checked in polynomial time but probably not solved in polynomial time P = NP is an open problem but most think P 6= NP.
Algorithms and NP