Introduction to Complexity
- Let P be the set of problems for which a polynomial time solution exists.
- These are the problems we consider to be "solvable"
- This set is closed under addition and multiplication
- let $a_1, a_2 \in P$
- Then $a_1 + a_2 \in P$ (What does this mean?)
- Then $a_1 * a_2 \in P$ (What does this mean?)
- A decision problem is a problem that has a yes/no answer.
- In CLRS
- They refer to a problem by a name
- PATH is an example of a decision problem.
- Given a Graph G=(V, E), and two vertices $u,v \in V$
does a path exist from u to v?
- Any solution to PATH will return a yes if such a path exists and no if it does not.
- They state that optimization problems can be recast as a decision problem with a bound.
- We will focus on decision problems for this topic.
- Polynomial time verification
- Given
- A graph G
- A path p in G
- A cost k, this is the bound
- Can we verify that this is a solution to PATH in polynomial time?
- Clearly we can do this in the length of p time.
- Let $p = \{u, n_1, n_2, ... n_{m-1}, v\}$
- let $u = n_0$ and $v = n_m$
- For each pair $(n_i, n_{i+1}), 0 \le i \lt k$ check to see if $(n_i, n_{i+1}) \in E$
- Check that $k = \sum\limits_0^{m-1}w(n_i, n_{i+1})$.
- The Hamiltonian Cycle problem (HAM_CYCLE)
- Given an undirected graph G=(V,E)
- Does there exist a path p that starts at a node, visits every other node once, and returns to the starting node without traversing any edge twice?
- Some images stolen from wikipedia
- What would it mean to verify a solution to HAM_CYCLE?
- Can this be done in polynomial time?
- By the way, we don't know a good solution to HAM_CYCLE
- HAM_PATH is just to find a path that visits all nodes exactly once where no edge is traversed twice.
- HAM_PATH is also hard.
- The class NP is the set of all decision problems which can be verified in polynomial time.
- IE Given a solution, can you check to see if the solution is right in polynomial time?
- We have seen that HAM-CYCLE $\in$ NP
- What about problems in P?
- Any problem in P has an algorithm that can solve it in Polynomial time.
- Therefore given an input to such a problem and a solution, just solve the problem in polynomial time and check the solution (remember this is a yes/no thing)
- Therefore $P \subset NP$
- It is a long standing problem, does $P = NP$?
- The standard belief is that this is not the case.