CS 411 Fall 2025 > Outline for November 21, 2025
CS 411 Fall 2025
Outline
for November 21, 2025
Outline
P, NP, NP-Complete [L 11.3]
- Tractability
- A problem specifies, for each of a number of possible legal inputs, one or more correct outputs. Each legal input an an instance of the problem.
- An algorithm solves a problem if, for each instance, it returns a correct output.
- An algorithm is polynomial-time
if its time complexity is \(O(p(n))\),
for \(p\) a polynomial.
- Equivalently, an algorithm is polynomial-time if its time complexity is \(O(n^k)\), for some constant \(k\).
- A problem is tractable if it is solved by a polynomial-time algorithm. Other problems are intractable.
- The theory of computational complexity concerns, among other things, which problems are tractable.
- \(\mathrm{P}\) & \(\mathrm{NP}\)
- A decision problem
is a problem whose answers are all “yes”
or ”no”.
- Instance that give the answers “yes” and “no” are yes-instances and no-instances, respectively.
- \(\mathrm{P}\) is the class of all decision problems that can be solved by a polynomial-time algorithm, i.e., the class of all tractable decision problems.
- The notion of algorithm we have discussed is, more precisely, a deterministic algorithm.
- A nondeterministic algorithm
has an intial guessing stage,
in which an arbitrary guess is generated.
This can then be used in later processing.
- A nondeterministic algorithm solves
a decision problem if,
- For each yes-instance, there is some guess that will result in the nondeterministic algorithm answering “yes”.
- The nondeterministic algorithm never gives an incorrect “yes” answer.
- Note that we do not require a nondeterministic algorithm to halt eventually. We also say it solves a decision problem even if it sometimes incorrectly answers “no”.
- The time complexity of a nondeterministic algorithm gives its greatest best-guess running time over all yes-instances of a certain size.
- A nondeterministic algorithm solves
a decision problem if,
- Example: nondeterministic algorithm to solve TSP.
- Reformulate TSP as a decision problem. Given a graph with weights on the edges, along with a budget, is there a cycle that hits every vertex whose total weight is at most the budget?
- Nondeterministic algorithm: check the guess to see whether it is the cycle we want. If so, answer “yes”.
- It is not known whether TSP is tractable. However, the time complexity of this nondeterministic algorithm is linear!
- \(\mathrm{NP}\) is the class of all decision problems that can be solved by a polynomial-time nondeterministic algorithm.
- It is easy to turn a polynomial-time deterministic algorithm into a polynomial-time nondeterministic algorithm; simply ignore the guess. So every problem in \(\mathrm{P}\) is also in \(\mathrm{NP}\).
- Does every problem in \(\mathrm{NP}\) also lie in \(\mathrm{P}\)? No one knows. TSP is in \(\mathrm{NP}\). It is not known whether TSP lies in \(\mathrm{P}\).
- A decision problem
is a problem whose answers are all “yes”
or ”no”.
\(\mathrm{P}\), \(\mathrm{NP}\), \(\mathrm{NP}\)-Complete will be continued next time.