Presentation is loading. Please wait.

Presentation is loading. Please wait.

What is Intractable? Some problems seem too hard to solve efficiently. Question 1: Does an efficient algorithm exist?  An O(a ) algorithm, where a > 1,

Similar presentations


Presentation on theme: "What is Intractable? Some problems seem too hard to solve efficiently. Question 1: Does an efficient algorithm exist?  An O(a ) algorithm, where a > 1,"— Presentation transcript:

1 What is Intractable? Some problems seem too hard to solve efficiently. Question 1: Does an efficient algorithm exist?  An O(a ) algorithm, where a > 1, runs in exponential time. n  An O(n ) algorithm runs in polynomial time. k not efficient (intractable) polynomial timeefficient (tractable) exponential time

2 NP-Completeness Question 2: If I can’t find a polynomial time algorithm, is the problem intractable? Don’t really know! Maybe … NP-completeness gives strong (but not definitive) evidence. No polynomial-time algorithm has been found. Neither has a proof that no such algorithm exists.

3 Decision Problems Recasting needed before applying NP-completeness theory: decision problems A question with Yes/No answer inputs with “Yes” answer inputs with “No” answer optimization problems

4 Ex a) Minimum Spanning Tree Input: Edge-weighted graph G, number N. Q: Does G have a spanning tree of total cost ≤ N ?  Solve the optimization problem (using Kruskal or Prim).  If M ≤ N, Yes; otherwise, No.  Let the solution tree have weight M.

5 Ex b) Longest Common Subsequence Input: Two sequences P and Q and integer k > 0. Q: Do P and Q have a common sequence of length  k?  Run the LCS algorithm (dynamic programming).  If l  k, Yes; otherwise, No.  Let the solution subsequence have length l.

6 Class P Why a decision problem? It is  no harder than its optimization version  cleaner  answering question like If A is hard, then is B hard too? Class P : the set of all problems solvable in polynomial time. Ex. a) and b) belong to class P.

7 Ex c) Subset Sum Q: Is there a set S'  S such that  x  S' x = t ? For instance, S = {1, 3, 5, 11} t = 10  No t = 15  Yes Input: a set of integers S = { a, a, …, a } and integer t 1 2 n

8 Solution of Subset Sum  Enumerate subsets S' of S  Verify the certificate S' (e.g., {1, 3, 11}) (a solution guess)              a 1 a 3 a 2 a 1 a 2 a 1 a 1 a 1 a 2 a 2 a 2 a 3 a 3 a 3 a 3 2 n subsets  exponential time

9 Faster Solution? Is there a faster polynomial-time solution? Probably not in P! A knapsack formulation:  knapsack capacity t  1$/lb for each item Running time O(nt). But t maybe exponential in n!

10 Ex d) Hamiltonian Cycle (HC) Input: Undirected graph G. Q: Does G have a cycle that goes through each vertex exactly once? Enumerate all permutations of vertices and check? Subset Sum and HC are NP-complete (NPC)! non-deterministic polynomial time hardest in NP (if such a problem can be efficiently solved, all problems in NP can.) Yes No


Download ppt "What is Intractable? Some problems seem too hard to solve efficiently. Question 1: Does an efficient algorithm exist?  An O(a ) algorithm, where a > 1,"

Similar presentations


Ads by Google