Upload
brian-henderson
View
212
Download
0
Embed Size (px)
Citation preview
1
NP Complete
Joe Meehean
2
Complexities we’ve seen
Log: binary search in sorted array
Linear: traverse a tree
Log-Linear: insert into a heap
Quadratic (N2): your sort from P1 Exponential (NN): brute force
map coloring
3
Polynomial Time Upper bound is Nk for N inputs
• e.g., O(logN), O(N), O(NlogN), O(N2), … Problems in class P
• have known polynomial time solutions
4
Non-deterministic vs. Deterministic
Slipping into computational theory Deterministic programs
• like the ones we write in C++• must search or construct the correct answer• if there are many possible solutions must
check them all• OR carefully construct the answer piece-
wise
5
Non-deterministic vs. Deterministic
Non-deterministic programs• currently exist only in theory• program guided by all knowing oracle• oracle can create a possible solution to the
problem for free• solution is often the correct one
if a solution exists
6
Non-deterministic Polynomial Time
Think about reducing problem to yes/no
Given a potential solution to problem• is it possible to determine whether it is
correct in polynomial time Problems like this are in the NP class
• if in NP, but not P then there is no known polynomial time solution for these problems
• but we can check answers in polynomial time
7
Non-deterministic Polynomial Time
e.g., graph coloring• given a potential coloring of vertices• for each vertex compare its colors to
its neighbors • O(E + V) = polynomial time• only need one correct k coloring to prove
graph can be colored with k colors
8
Problem Complexity
NP
P
9
NP Complete Problems Hardest problems in NP Any problem in NP can be polynomially
reduced to all NP complete problems• NP problem A can be translated into NP
complete problem B in polynomial time• e.g. calculator
numbers entered in decimal converted to binary and solved in binary converted back to decimal
Min color graph coloring is NP complete
10
Problem Complexity
NP
P NP Complete
maybe
11
NP Complete If we can solve an NP complete
problem A in polynomial time• we can use it as a method (sub routine) to
solve other NP problem B• just translate the B into A in polynomial
time• solve A• translate solution back into B• polynomial time + polynomial time =
polynomial time
12
NP Complete If we can solve an NP complete
problem A in polynomial time• we can solve ALL NP problems in
polynomial time• P = NP
13
Problem Complexity
NP
P
NP Complete
14
NP Complete P = NP? No one has solved an NP complete
problem in polynomial time …Yet
15
Undecidable problems Problems that are impossible to
solve using a Turing machine-based computer• impossible to solve with modern
computers E.g., halting problem
• does a program have an infinite loop?• proof is simple to explain• proof is hard to understand
involves recursion and impossible outcomes
16
Questions?