PNP Problems
PNP Problems
Tractability
Intractable Problems: as they grow large, we are
unable to solve them in reasonable time
What constitutes reasonable time? Standard
working definition: polynomial time
Is there a polynomial-time algorithm that solves the
problem?
On an input of size n the worst-case running time is
O(nk ) for some constant k
Yes: Polynomial time: O(n2), O(n3), O(1), O(nlgn)
No: Not in polynomial time: O(2n), O(nn), O(n!)
Polynomial-Time Algorithms
Are some problems solvable in polynomial time?
Of course: every algorithm weve studied provides
polynomial-time solution to some problem
Are all problems solvable in polynomial time?
No: Turings Halting Problem is not solvable by any
computer, no matter how much time is given
Most problems that do not yield polynomial-time
algorithms are either optimization or decision
problems
Optimization / Decision Problems
Optimization Problems :
An optimization problem is one which asks, What is
the optimal solution to problem X?
Examples:
0-1 Knapsack
Fractional Knapsack
Minimum Spanning Tree
Decision Problems:
An decision problem is one which asks, Is there a
solution to problem X with property Y?
Examples:
Does a graph G have a MST of weight W?
Optimization / Decision Problems
An optimization problem tries to find an optimal
solution
A decision problem tries to answer a yes/no
question
Many problems will have decision and
optimization versions
Example:
Traveling salesman problem
Optimization: Find Hamiltonian cycle of minimum
weight
Decision: Find Hamiltonian cycle of weight < k
The Class P
P: the class of decision problems that have
polynomial-time deterministic algorithms
That is, they are solvable in O(p(n)), where p(n) is a
polynomial on n
A deterministic algorithm is one that always computes
the correct answer
Examples:
Fractional Knapsack
MST
Single-source shortest path
Sorting
The Class NP
NP: the class of decision problems that are solvable in
polynomial time on a non-deterministic machine (or
with a non-deterministic algorithm)
A nondeterministic computer is one that can guess the
right answer or solution