NP Complete Introduction
Objectives
Notes
- This is very informal, it is not rigorous
- We begin to talk about problems, not algorithms.
- P is the set of problems that we can solve in polynomial time.
- There exists an algorithm with performance O(nk), k an integer constant, the size of the input.
- NP is a set of problems that we can check in polynomial time
- Ie if C is a solution (or certificate) to a problem.
- There is an algorithm A(I, C) , O(nk) for constant integer k, that determines if C is the correct solution for input I.
- An example
- The input to a sorting problem is the array A
- The output of a sorting algorithm is A', the ordered array
- What algorithm can we use to check to see if A' is in order?
- Is this a polynomial time algorithm?
- The Sorting is an element of the set NP
- Any problem in P is also in NP
Check(Input, Certificate) Use the polynomial time algorithm to find the solution to the given input Check to see if this matches the certificate
- Therefore P ⊆ NP
- The subset NP-Complete (NPC) is a set of problems that
- Are in NP
- And are as hard as any other problem in NP
- In some sense here we are not looking at how easy a problem is, but how hard it is.
- Think the lower bounds on sorting.
- We frequently look at decision problems
- These are problems which given a set if input produce a yes or a no.
- Given a circuit, can a set of input be found to make the circuit true?
- Given a graph, can I find a cycle that visits every vertex exactly once?
- These problems are easy to test,
- I take the circuit and the input that supposedly produces a true and evaluate it.
- I trace the proposed cycle in the graph and see if it visits all vertexes.
- Decision problems can be mapped to optimization problems
- We transform an optimization into a series of "Can this be done in time 1, in time 2, ... up to time n, the size of the input.
- Note this is a polynomial loop, O(n) + time to solve problem.
- We will be somewhat sloppy here too, decision, optimization, whatever
- Reductions
- Let A and B both be decision problems.
- A problem A can be reduced to a problem B, A ≤ B
- There is an algorithm that transforms the data for A to data for B
- The output from B (yes, no) is also the output for B.
- If this can be done in polynomial time, A ≤pB
- If we can reduce one problem to another, it is no harder than the second
- To find the kth item in data we could
Sort the list of data return data[k] - Thus the task of finding the kth item is no harder than sorting.
- (I know this is not a decision problem, but it will do for now)
- To find the kth item in data we could
- So if I can reduce any problem, in polynomial time, to a polynomial problem, it is also polynomial.
- Finding the kth element ≤P sorting
- Sorting ⊂ P
- Thus Finding the kth element ⊂ P
- Generally we
- Can show a problem is in P by producing an algorithm.
- show something is in NP by showing we can check it in P and not having an algorithm that shows it is in P.
- In a graph, can we find a path that visits every vertex of a graph exactly once? This is the Hamiltonian path problem or HAM-PATH
- We don't know a good way to solve it, so it is not in P
- We do know a good way to check it, so it is in NP
- NP-Complete is a way to try to fix this.
- Ie if we can reduce any problem in the set NP-COMPLETE to a problem P in polynomial time,
- Then we solve P in polynomial time
- We can solve every problem in NP in polynomial time.
- We actually have a large set of problems in NP-Complete
- Wikipedia has a list.
- But this is not a full list.
- We will look at some of these problems on Monday
- But we don't know how to solve ANY of these problems quickly.
- A few more notes
- NP are hard problmes we can check easily
- NP-Complete are hard problems we can check easily and all problems in NP can be reduced to them
- NP-Hard are problems that eveything in NP-Complete can be reduced to, but we might not be able to check them easily
-
- So the question is: does P = NP?