Share
Embed
Transcript
27 slides
-
Example Given a list... [20, 1, 5323, 2319, 2387, 0,
27, 23] Question: Is 20 in the list ? Question: What is the biggest number in the list? Question: What should be the next number? -
P P : all decision problems , some of them:
1. You can verify the solution easily. 2. You can (or some people can) solve it in a polynomial-time A turing machine -
Example 3-SUM Given a set S of n integers, are
there elements a, b, c in S ? a + b + c = 0 You can do so in O(n2) time -
Example -25 -10 -7 -3 2 4 8 10 (a+b+c==-25)
-25 -10 -7 -3 2 4 8 10 (a+b+c==-22) . . . -25 -10 -7 -3 2 4 8 10 (a+b+c==-7) -25 -10 -7 -3 2 4 8 10 (a+b+c==-7) -25 -10 -7 -3 2 4 8 10 (a+b+c==-3) -25 -10 -7 -3 2 4 8 10 (a+b+c==2) -25 -10 -7 -3 2 4 8 10 (a+b+c==0) Yet, to solve 3SUM, we used a subquadratic-time algorithm -
Example Minimum spanning tree Given a connected, undirected graph, a
spanning tree of that graph is a subgraph that is a tree and connects all the vertices together. Famous DFS/ BFS / Dijkstra's algorithm Work within O(|V|2) -
How hard? 1. You can verify the solution easily. 2.
But you (nor neither others in the world) can not solve it in a polynomial-time Definition NP stands for nondeterministic polynomial time, a term going back to the roots of complexity theory. Intuitively, it means that a solution to any search problem can be found and verified in polynomial time by a special (and quite unrealistic) sort of algorithm, called a nondeterministic algorithm. Such an algorithm has the power of guessing correctly at every step. -
Example Euler's path Find a path that one exactly walks
across each bridge once -
Example Clique finding the maximum clique (a clique with the
largest number of vertices) finding a maximum weight clique in a weighted graph listing all maximal cliques (cliques that cannot be enlarged) solving the decision problem of testing whether a graph contains a clique larger than a given size. I suspect it's hard... but how to show its HARDNESS? -
Approach to solve... Anyway, when we try to solve a
problem.. 1. You know how to solve it... (DONE) 2. You don't know how to solve the current problem... Reduce it to another similar problem! If you know how to solve it -
Reduction Independent set Vertex cover Find maximum independent sets such
that v 1 , v 2 , v n do not have an edge connecting them Find min. vertex number to cover the graph G VertexCover(G,k) G' = G k' = |V| - k return IndependentSet(G',k') -
NP-complete THEOREM If any NP-complete problem is solvable in polynomial
time, then P = NP. If any NP-complete problem is not solvable in polynomial time, then P != NP. THEOREM 2 (Cook (1971) and Levin (1973)) Satisfiability is NP-complete. A search problem is NP-complete if all other search problems reduce to it -
Basic NP-complete Problems 3-Satisfiability (3SAT) Vertex Cover Instance: An undirected
graph G and an integer K Question: Is there a vertex cover of size K or less for G, i. e., a subset V' of V with the size of V' less than K such that every edge has at least one endpoint in V'. C1 = (x1 V x2 V x3) C2 = (x2 V x3 V x4) C3 = (x1 V x2 V x4) C4 = (x1 V x3 V x4) Question: Find values for x1 to x4 that C1 && C2 && C3 && C4 -> true -
Deal with NP Heuristics Relies on ingenuity, intuition, good understanding
of the application, experiments and often insights from physics or biology to attack a problem Approximation algorithms So, when faced with an NP-complete optimization problem, a reasonable goal is to look for an approximation algorithm A to obtain a nearest solution for the problem. Fixed-Parameter Tractable algorithm (FPT) Parameterized the problem, which makes it to be solvable in polynomial complexity time limit. Reduce the scale of the NP-hard problem. -
NP vs P Some people are trying to prove P
== NP One of the Millennium Prize Problems -
Implications We are making good use of P every day
E.g. Is Key K the correct key for decryption function f(x,k) ? Some NP question maybe... E.g. Find ALL correct key for decryption function f(x,k) . -
Implications Knowing NP Design specific algorithm to tackle it. To
solve in other ways Appoximation Fixed-Parameter Tractable algorithm (FPT) -
Implications If P = NP ? Many of the problems
we know to be in NP or NP-complete are problems that we actually want to solve. By reduction ... NP P SOLVED polynomial time polynomial time -
Know more General definition and examples http://compgeom.cs.uiuc.edu/~jeffe/teaching/algorithms/notes/21-nphard.pdf http://www.cs.berkeley.edu/~vazirani/algorithms/chap8.pdf Battleship example
http://www.mountainvistasoft.com/docs/BattleshipsAsDecidabilityProblem.pdf List of NPC problems http://en.wikipedia.org/wiki/List_of_NP-complete_problems