NP Completeness
NP Completeness
NP Completeness
●
Tractable
– If there exists at least one polynomial bound
algorithm (nk)
– Run fast
●
Intractable
– If the problem is not tractable then it is intractable
– Run slow
Intractable
●
Difficult to solve
●
For large value or range of input it will take a lot
time to solve
●
Example: travelling salesman problem
So what we do?
●
We dont look for exact answers
– Example: in travelling salesman problem we are not
interested in finding shortest route but we want to
find out the route between two nodes.
– This approach is called as heuristic ( or
approximation) that is we are looking for some
solution which may be not a optimal solution or
exact solution.
– Approximation soliutions run faster.
Un-decidable Problems
●
No algorithm exists
●
Example: halting problem of turing machine
Some examples
●
Shortest path problem is tractable
– What is think about longest path problem?
●
Eulers tour : every edge is repeated exactly
once
– It is tractable
●
Hamiltonion cycle: every vertex is repeated
exactly once
– Intractable
– Sub problem of travelling salesman problem
Optimization Problems
●
Optimzation problems :
– TSP
– 0/1 Knapsack
– LCS
●
In all the problems above we are looking for
optimal solution
How to know whether problem is easy or hard
to solve?
– We go for some subproblem and work on it
– If is his hard to solve then bigger problem is also
hard to solve
– Example: in TSP one subproblem may be “ is there
any shortest path covering all vextex of lengh
atmost k?”
Decision Problems
●
Given some input
●
And a decision problem
●
And a answer
●
Suppose somesome has solved optimization
problem
●
Someone has given you a answer
●
P is a set of all DP for which there exists a
polynomial time algorithm to solve
●
NP is a set of all DP for which there exists a
polynomial time verfication algorithm
●
If you solve the problem in polyomial time then
you can verify the problem in polynomial time
●
So every P class problem there will be
verfication algorithm which runs in a polynomial
time.
So
every problem in P will also be in NP
So the millions dollar question is :
P = NP
●
There are many problems which are in NP but
not in P like TSP, 0/1 Knapsack.
●
So if someone solve these in polynomial time
then these belong to P.
●
So as of now (NP-P) is intractable.
●
Since 1971, no one able to give polynomial time
solution to (NP-P) problems nor any proof that
these can not be solved in polynomial time.
●
We can not solve all the (NP – P) problems in
polynomial time.
●
We can come up with some problem which is
harder than (NP – P) problems.
●
If we solve that problem in polynomial time then
all other (NP – P) problem can be solved in
polynomial time.
Reducability
Reducability
●
Given n boolean variables with value
x1,x2,x3...xn, does at least one variable have the
value “True’.’
– (T,F,T,F)
● Given n integers i1,i2,i3.....in is
max(i1,i2,i3.....in > 0)
– (20,0,3,-2)
Example Continued..