1 Pseudo-polynomial time algorithm (The concept and the terminology are important) Partition Problem: Input: Finite set A=(a 1, a 2, …, a n } and a size.

Slides:



Advertisements
Similar presentations
Polynomial Time Approximation Schemes for Euclidean TSP Ankush SharmaA H Xiao LiuA E Tarek Ben YoussefA
Advertisements

CS 336 March 19, 2012 Tandy Warnow.
Greedy Algorithms Greed is good. (Some of the time)
Polynomial-time reductions We have seen several reductions:
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,
1 NP-completeness Lecture 2: Jan P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many.
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Concept of Completeness and hardness for a complexity class Definition.
Complexity class NP Is the class of languages that can be verified by a polynomial-time algorithm. L = { x in {0,1}* | there exists a certificate y with.
NP-Complete Problems Polynomial time vs exponential time
The Theory of NP-Completeness
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
Parallel Scheduling of Complex DAGs under Uncertainty Grzegorz Malewicz.
CPSC 668Set 10: Consensus with Byzantine Failures1 CPSC 668 Distributed Algorithms and Systems Fall 2009 Prof. Jennifer Welch.
Computational problems, algorithms, runtime, hardness
1 Pseudo-polynomial time algorithm (The concept and the terminology are important) Partition Problem: Input: Finite set A=(a 1, a 2, …, a n } and a size.
1 Pseudo-polynomial time algorithm (The concept and the terminology are important) Partition Problem: Input: Finite set A=(a 1, a 2, …, a n } and a size.
Balanced Graph Partitioning Konstantin Andreev Harald Räcke.
CPSC 668Set 10: Consensus with Byzantine Failures1 CPSC 668 Distributed Algorithms and Systems Fall 2006 Prof. Jennifer Welch.
1 Vertex Cover Problem Given a graph G=(V, E), find V' ⊆ V such that for each edge (u, v) ∈ E at least one of u and v belongs to V’ and |V’| is minimized.
The Theory of NP-Completeness
1 Assignment 4. This one is cancelled since there is a solution on website. I new assignment will be given on Nov. 28. (Due on Friday of Week 14. Drop.
1 More On Dynamic programming Algorithms Shortest path with edge constraint: Let G=(V, E) be a directed graph with weighted edges. Let s and v be two vertices.
88- 1 Chapter 8 The Theory of NP-Completeness P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class.
NP-Completeness NP-Completeness Graphs 4/17/2017 4:10 AM x x x x x x x
Dynamic Programming1. 2 Outline and Reading Matrix Chain-Product (§5.3.1) The General Technique (§5.3.2) 0-1 Knapsack Problem (§5.3.3)
Time Complexity.
1 NP-Complete Problems Polynomial time vs exponential time –Polynomial O(n k ), where n is the input size (e.g., number of nodes in a graph, the length.
Pseudo-polynomial time algorithm (The concept and the terminology are important) Partition Problem: Input: Finite set A=(a1, a2, …, an} and a size s(a)
Chapter 11: Limitations of Algorithmic Power
NP-Complete Problems (Fun part)
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 22 Instructor: Paul Beame.
DAST 2005 Week 4 – Some Helpful Material Randomized Quick Sort & Lower bound & General remarks…
Dynamic Programming 0-1 Knapsack These notes are taken from the notes by Dr. Steve Goddard at
Computability and Complexity 17-1 Computability and Complexity Andrei Bulatov Strong NP-Completeness.
1 Dynamic Programming Jose Rolim University of Geneva.
1 NP-Complete Problems (Fun part) Polynomial time vs exponential time –Polynomial O(n k ), where n is the input size (e.g., number of nodes in a graph,
1 The Theory of NP-Completeness 2 NP P NPC NP: Non-deterministic Polynomial P: Polynomial NPC: Non-deterministic Polynomial Complete P=NP? X = P.
Assignment 4. (Due on Dec 2. 2:30 p.m.) This time, Prof. Yao and I can explain the questions, but we will NOT tell you how to solve the problems. Question.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
MCS312: NP-completeness and Approximation Algorithms
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Design Techniques for Approximation Algorithms and Approximation Classes.
Theory of Computing Lecture 15 MAS 714 Hartmut Klauck.
Mathematical Preliminaries Strings and Languages Preliminaries 1.
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
The Lower Bounds of Problems
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
Polynomial-time reductions We have seen several reductions:
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
Unit 9: Coping with NP-Completeness
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
1.1 Chapter 3: Proving NP-completeness Results Six Basic NP-Complete Problems Some Techniques for Proving NP-Completeness Some Suggested Exercises.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
LIMITATIONS OF ALGORITHM POWER
Analysis & Design of Algorithms (CSCE 321)
Algorithms for hard problems Introduction Juris Viksna, 2015.
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
NP-complete Languages
Introduction to NP Instructor: Neelima Gupta 1.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design Advanced Algorithms Analysis and Design By Dr. Nazir Ahmad Zafar.
The NP class. NP-completeness
All-pairs Shortest paths Transitive Closure
Pseudo-polynomial time algorithm (The concept and the terminology are important) Partition Problem: Input: Finite set A=(a1, a2, …, an} and a size s(a)
Presentation transcript:

1 Pseudo-polynomial time algorithm (The concept and the terminology are important) Partition Problem: Input: Finite set A=(a 1, a 2, …, a n } and a size s(a) (integer) for each a  A. Question: Is there a subset A’  A such that  a  A’ s(a) =  a  A –A’ s(a)? Theorem: Partition problem is NP-complete (Karp, 1972). An dynamic algorithm: For i  n and j  0.5  a  A s(a), define t(i, j) to be true if and only if there is a subset A i of {a 1, a 2, …, a i } such that  a  Ai s(a)=j. Formula: T(i,j)=true if and only if t(i-1, j)=true or t(i-1, j-s(a i ))=true.

2 Example i TTFFFFFFFFFFFF 2TTFFFFFFFTTFFF 3TTFFFTTFFTTFFF 4TTFTTTTFTTTFTT 5TTFTTTTFTTTTTT Figure 4.8 Table of t(i,j) for the instance of PARTITION for which A={a 1,a 2,a 3,a 4,a 5 }, s(a 1 )=1, s(a 2 )=9, s(a 3 )=5, s(a 4 )=3, and s(a 5 )=8. The answer for this instance is "yes", since t(5,13)=T, reflecting the fact that s(a 1 )+s(a 2 )+s(a 4 )=13=26/2. j

3 Backtracking if t(n, W) is not true then print “ no such partition” and stop; i=n; w=W; if ( t(n, W)== false) then stop; While (i> 0 ) do { if (t(i, w) == true) { if (t(i-1, W)== true) then i=i-1; else { W=W-s(a i ); i=i-1; print “a i ”} }

4 Time complexity The algorithm takes at most O(nB) time to fill in the table. (Each cell needs constant time to compute). Do we have a polynomial time algorithm to solve the Partition Problem and thus all NP-complete problems? –No. –O(nb) is not polynomial in terms of the input size. S(a i )=2 n =10000…0. (binary number of n+1 bits, n 0’s). So B is at least O(2 n ). The input size is O(n) if there some a i with S(a i )=2 n. B is not polynomial in terms of n (input size) in general. However, if any upper bound is imposed on B, (e.g., B is Polynomial), the problem can be solved in polynomial time for this special case. (This is called pseudo-polynomial.)

5 0-1 version

6

7

8

9

10

11

12

13

14

15

16

17 RNA Sequence: ACCGGUAGU

18 Exercise: Let T be a rooted binary tree, where each internal node in the tree has two children and every node (except the root) in T has a parent. Each leaf in the tree is assigned a letter in  ={A, C, G, T}. Figure 1 gives an example. Consider an edge e in T. Assume that every end of e is assigned a letter. The cost of e is 0 if the two letters are identical and the cost is 1 if the two letters are not identical. The problem here is to assign a letter in  to each internal node of T such that the cost of the tree is minimized, where the cost of the tree is the total cost of all edges in the tree. Design a polynomial-time dynamic programming algorithm to solve the problem.

19 A A C Figure 1 A

20 Assignment 4. (Due on May 2, Drop it in Mail Box 59) This time, Helena and I can explain the questions, but we will NOT tell you how to solve the problems. Question 1. Give a polynomial time algorithm to find the longest monotonically increasing subsequence of a sequence of n numbers. (Assume that each integer appears once in the input sequence of n numbers) Example: Consider sequence 1,8, 2,9, 3,10, 4, 5. Both subsequences 1, 2, 3, 4, 5 and 1, 8, 9, 10 are monotonically increasing subsequences. However, 1,2,3, 4, 5 is the longest.

21 Assignment 4. (Due on May 2, 2007) Question 2. Given an integer d and a sequence of integers s=s 1 s 2 …s n. Design a polynomial time algorithm to find the longest monotonically increasing subsequence of s such that the difference between any two consecutive numbers in the subsequence is at least d. Example: Consider the input sequence 1,7,8, 2,9, 3,10, 4, 5. The subsequence 1, 2, 3, 4, 5 is a monotonically increasing subsequence such that the difference between any two consecutive numbers in the subsequence is at least 1. 1, 3, 5 is a monotonically increasing subsequence such that the difference between any two consecutive numbers in the subsequence is at least 2.

22 Assignment 4. (Due on May 2, 2007) Question 3. Suppose that there are n sequences s 1, s 2, …, s n on alphabet  ={a 1, a 2, …, a m }. Every sequence s i is of length m and every letter in  appears exactly once in each s i. Design a polynomial time algorithm to compute the LCS of the n sequences. What is the time complexity of your algorithm?