CSCE 411 Lecture 30
« previous | Wednesday, November 7, 2012 | next »
Categorization of Problems
We'll consider a computational problem tractable iff it can be solved in polynomial time ( for some )
Class P
tractable decision problems (with yes/no answer)
Class NP
All decision problems for which a candidate solution can be verified in polynomial time.
(We may not be able to find the solution, but we can verify the solution in polynomial time if someone is so kind to give us the solution.)
P is a subclass of NP, but ...
Many practical problems in computer science, math, operations research, engineering, etc. are poly time verifiable but have no known poly time algorithm.
Sudoku
The problem is given as an array which is divided into blocks of squares.
Some array entries are filled with an integer in the range .
Goal is to complete the array such that each row, column, and block contains each integer from .
It's difficult to solve, but easy to check.
Hamiltonian Cycle
A Hamiltonian cycle in an undirected graph is a cycle that visits every node exactly once.
Solving a problem: is there a Hamiltonian cycle in graph ?
Verifying a candidate solution: Is a Hamiltonian cycle of graph ?
P v. NP
Although poly-time verifiability seems like a weaker condition than poly time solvability, no one has been able to prove that it is weaker (i.e. it describes a larger class of problems).
So it's unknown whether
Question posed in around 1970
- Great theoretical interest
- Great practical importance:
- If your problem is NP-complete, then don't waste time looking for an efficient algorithm. Instead look for efficient approximations, heuristics, etc.
Two cases:
NP-Complete Problems
Class of "hardest" problems in NP, symbol is NPC
If an NP complete problem can be solved in poly time, then all NP problems can be solved in poly time.
Two cases become:
- , ,
Decision Problems and Formal Languages
Language: A set of strings over some alphabet
Every abstract problem has to be represented somehow for the computer to work on it (binary)
Consider "Is prime?". Numbers have to be stored in binary.
P is set of decision problems that can be computed in time where is the length of the input string and is a constant.
"Computed" means there is an algorithm returns YES or NO whether the string is in the language.
Verifying to solving:
candidates.each do |solution|
return :yes if solution.works?
no
end
"Does have a Hamiltonian cycle?": candidates
Polynomial Reduction
Relating one decision problem with another
polynomial reduction (or transformation) from language to language is a function from strings over 's alphabet to strings over 's alphabet such that
Take a decision problem and somehow magically encode input as a sudoku problem.
is at least as hard as :
- and
- computable in poly time
- Notation