Review Big O and Algorithms Master Theorem Complexity vs NP

NP

G. Carl Evans

University of Illinois

Summer 2013

NP Review Big O and Algorithms Master Theorem Complexity P vs NP Outline

1 Review Big O and Algorithms

2 Master Theorem

3 Complexity

4 P vs NP

NP Review Big O and Algorithms Master Theorem 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!

NP Review Big O and Algorithms Master Theorem Complexity P vs NP Example: multiplying large numbers

Multiplying small numbers in binary

101 ×011

Complexity: m m Multiplying large numbers x = x12 + x0 and y = y12 + y0

m m xy = (x12 + x0)(y12 + y0) 2m m = x1y12 + (x0y1 + y0x1)2 + x0y0

Complexity:

NP Review Big O and Algorithms Master Theorem Complexity P vs NP Example: multiplying large numbers

m m Multiplying large numbers x = x12 + x0 and y = y12 + y0

m m xy = (x12 + x0)(y12 + y0) 2m m = x1y12 + (x0y1 + y0x1)2 + x0y0

Trick by Anatolii Karatsuba

(x0y0 + y0x1) = (x1 + x0)(y1 + yo) − x1y1 − x0y0

Complexity:

NP Review Big O and Algorithms Master Theorem 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)

NP Review Big O and Algorithms Master Theorem Complexity P vs NP Master Theorem

n  T (n) = aT + f (n) where a ≥ 1, b > 1 b

NP Review Big O and Algorithms Master Theorem Complexity P vs NP Leaf term dominates

n  T (n) = aT + f (n) where a ≥ 1, b > 1 b

c logba If f (n) = Θ(n ) with c < logb a, then T (n) = Θ(n ) n  Example: T (n) = 4T 2 + O(n)

NP Review Big O and Algorithms Master Theorem Complexity P vs NP Balanced expansion

n  T (n) = aT + f (n) where a ≥ 1, b > 1 b c k If f (n) = Θ(n log n) with k ≥ 0, c = logb a, then T (n) = Θ( logk+1 n) n  Example: T (n) = 2T 2 + O(n)

NP Review Big O and Algorithms Master Theorem Complexity P vs NP Slow expansion

n  T (n) = aT + f (n) where a ≥ 1, b > 1 b c c If f (n) = Θ(n ) with c > logb a, then T (n) = Θ(n ) n  2 Example: T (n) = 2T 2 + O(n )

NP Review Big O and Algorithms Master Theorem 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} Complexity Classes BQP/mpoly NE/poly XOR-MIP*[2,1] QMA(2) QIP[2] IP RP^{NP} frIP 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 Inherent Complexity BPP/mlog HeurBPP YPP N.BPP PZK AmpP-BQP RPE BPQP UE BH ModP 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

+/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

NP Review Big O and Algorithms Master Theorem 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.

NP Review Big O and Algorithms Master Theorem 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.

NP Review Big O and Algorithms Master Theorem Complexity P vs NP Examples Sorting

Given a array of integers can you sort the set.

NP Review Big O and Algorithms Master Theorem Complexity P vs NP Examples Graph Coloring

Determining if the graph is n-colorable

Determining if the graph is not (n+1)-colorable

NP Review Big O and Algorithms Master Theorem 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

NP Review Big O and Algorithms Master Theorem 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)

NP Review Big O and Algorithms Master Theorem Complexity P vs NP How it fits together

P NP NP-complete NP-Hard

NP Review Big O and Algorithms Master Theorem 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.

NP