Partition of weighted sets (problems with numbers)

Σχετικά έγγραφα
ΑΛΓΟΡΙΘΜΟΙ Άνοιξη I. ΜΗΛΗΣ

ΑΛΓΟΡΙΘΜΟΙ Άνοιξη I. ΜΗΛΗΣ

Αλγόριθμοι και πολυπλοκότητα NP-Completeness (2)

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

Fractional Colorings and Zykov Products of graphs

The Simply Typed Lambda Calculus

ΑΛΓΟΡΙΘΜΟΙ Άνοιξη I. ΜΗΛΗΣ

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

ΑΛΓΟΡΙΘΜΟΙ Άνοιξη I. ΜΗΛΗΣ

Αλγόριθμοι και πολυπλοκότητα NP-Completeness

Homework 3 Solutions

C.S. 430 Assignment 6, Sample Solutions

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

Chapter 9: NP-Complete Problems

Matrices and Determinants

Nowhere-zero flows Let be a digraph, Abelian group. A Γ-circulation in is a mapping : such that, where, and : tail in X, head in

2 Composition. Invertible Mappings

EE512: Error Control Coding

New bounds for spherical two-distance sets and equiangular lines

Μη Ντετερμινισμός και NP-Πληρότητα

Inverse trigonometric functions & General Solution of Trigonometric Equations

Other Test Constructions: Likelihood Ratio & Bayes Tests

Finite Field Problems: Solutions

Reminders: linear functions

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

Section 8.3 Trigonometric Equations

Every set of first-order formulas is equivalent to an independent set

k A = [k, k]( )[a 1, a 2 ] = [ka 1,ka 2 ] 4For the division of two intervals of confidence in R +

Abstract Storage Devices

Graph Algorithms. Παρουσίαση στα πλαίσια του μαθήματος «Παράλληλοι Αλγόριθμοι» Καούρη Γεωργία Μήτσου Βασιλική

HY380 Αλγόριθμοι και πολυπλοκότητα Hard Problems

The ε-pseudospectrum of a Matrix

ω ω ω ω ω ω+2 ω ω+2 + ω ω ω ω+2 + ω ω+1 ω ω+2 2 ω ω ω ω ω ω ω ω+1 ω ω2 ω ω2 + ω ω ω2 + ω ω ω ω2 + ω ω+1 ω ω2 + ω ω+1 + ω ω ω ω2 + ω

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

The challenges of non-stable predicates

ST5224: Advanced Statistical Theory II

Network Algorithms and Complexity Παραλληλοποίηση του αλγορίθμου του Prim. Αικατερίνη Κούκιου

Chapter 6: Systems of Linear Differential. be continuous functions on the interval

TMA4115 Matematikk 3

Quadratic Expressions

Ordinal Arithmetic: Addition, Multiplication, Exponentiation and Limit

ΑΛΓΟΡΙΘΜΟΙ Άνοιξη I. ΜΗΛΗΣ

Partial Differential Equations in Biology The boundary element method. March 26, 2013

Example Sheet 3 Solutions

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

Lecture 15 - Root System Axiomatics

SCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions

SOLUTIONS TO MATH38181 EXTREME VALUES AND FINANCIAL RISK EXAM

Κατώτερα φράγματα Κατώτερο φράγμα: εκτίμηση της ελάχιστης εργασίας που απαιτείται για την επίλυση ενός προβλήματος. Παραδείγματα: Αριθμός συγκρίσεων π

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible.

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

ΑΛΓΟΡΙΘΜΟΙ Άνοιξη I. ΜΗΛΗΣ

Practice Exam 2. Conceptual Questions. 1. State a Basic identity and then verify it. (a) Identity: Solution: One identity is csc(θ) = 1

Distances in Sierpiński Triangle Graphs

PARTIAL NOTES for 6.1 Trigonometric Identities

Μη Ντετερμινισμός και NP-Πληρότητα

SOLUTIONS TO MATH38181 EXTREME VALUES AND FINANCIAL RISK EXAM

Statistical Inference I Locally most powerful tests

Econ 2110: Fall 2008 Suggested Solutions to Problem Set 8 questions or comments to Dan Fetter 1

LTL to Buchi. Overview. Buchi Model Checking LTL Translating LTL into Buchi. Ralf Huuck. Buchi Automata. Example

Lecture 2. Soundness and completeness of propositional logic

ANSWERSHEET (TOPIC = DIFFERENTIAL CALCULUS) COLLECTION #2. h 0 h h 0 h h 0 ( ) g k = g 0 + g 1 + g g 2009 =?

Θεωρία Γραφημάτων Θεμελιώσεις-Αλγόριθμοι-Εφαρμογές

Congruence Classes of Invertible Matrices of Order 3 over F 2

derivation of the Laplacian from rectangular to spherical coordinates

Numerical Analysis FMN011

Homework 8 Model Solution Section

Minimum Spanning Tree: Prim's Algorithm

Cyclic or elementary abelian Covers of K 4

Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3

CE 530 Molecular Simulation

A Hierarchy of Theta Bodies for Polynomial Systems

Tridiagonal matrices. Gérard MEURANT. October, 2008

ΑΛΓΟΡΙΘΜΟΙ Άνοιξη I. ΜΗΛΗΣ

2. THEORY OF EQUATIONS. PREVIOUS EAMCET Bits.

( )( ) ( ) ( )( ) ( )( ) β = Chapter 5 Exercise Problems EX α So 49 β 199 EX EX EX5.4 EX5.5. (a)

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

A Note on Intuitionistic Fuzzy. Equivalence Relation

About these lecture notes. Simply Typed λ-calculus. Types

D Alembert s Solution to the Wave Equation

Fourier Series. MATH 211, Calculus II. J. Robert Buchanan. Spring Department of Mathematics

Chapter 6: Systems of Linear Differential. be continuous functions on the interval

Areas and Lengths in Polar Coordinates

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 11/3/2006

Bounding Nonsplitting Enumeration Degrees

Approximation of distance between locations on earth given by latitude and longitude

ΕΙΣΑΓΩΓΗ ΣΤΗ ΣΤΑΤΙΣΤΙΚΗ ΑΝΑΛΥΣΗ

6.3 Forecasting ARMA processes

Sequent Calculi for the Modal µ-calculus over S5. Luca Alberucci, University of Berne. Logic Colloquium Berne, July 4th 2008

MINIMAL CLOSED SETS AND MAXIMAL CLOSED SETS

Μη Ντετερμινισμός και NP-Πληρότητα

Math 6 SL Probability Distributions Practice Test Mark Scheme

Math 446 Homework 3 Solutions. (1). (i): Reverse triangle inequality for metrics: Let (X, d) be a metric space and let x, y, z X.

ΕΛΛΗΝΙΚΗ ΔΗΜΟΚΡΑΤΙΑ ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΡΗΤΗΣ. Ψηφιακή Οικονομία. Διάλεξη 10η: Basics of Game Theory part 2 Mαρίνα Μπιτσάκη Τμήμα Επιστήμης Υπολογιστών

SCITECH Volume 13, Issue 2 RESEARCH ORGANISATION Published online: March 29, 2018

Το Πρόβλημα Routing and Path Coloring και οι εφαρμογές του σε πλήρως οπτικά δίκτυα

Srednicki Chapter 55

Second Order Partial Differential Equations

Section 7.6 Double and Half Angle Formulas

Transcript:

TOPICS IN ALGORITHMS http://eclass.aueb.gr/courses/inf7/ Spring 27 I. ΜILIS Partition of weighted sets (problems with numbers) AUEB / DoI / TOPICS IN ALGORITHMS / Spring 27 / I. MILIS / 6 - PARTITIONS

Weighted set problems SUBSET SUM I: objects S={,,n}, positive integer weights w i, i=,,n, positive integer W Q: is there A Í S s.t. = W? PARTITION I: objects S={,,n}, positive integer weights w i, i=,,n Q: is there A Í S s.t? - KNAPSACK I: objects S={,,n}, positive integer weights w i, i=,,n, values v i, i=,,n, positive integer W å Q: find A Í S s.t. w W and is maximized. i iîa AUEB / DoI / TOPICS IN ALGORITHMS / Spring 27 / I. MILIS / 6 - PARTITIONS 2

BIN PACKING Weighted set problems I: objects S={,,n}, positive integer weights w i, i=,,n, positive integer W Q: find a partition of S into s.t. and m is minimized å iî A j wi W, j =,2,..., m SCHEDULING (P C max ) I: objects S={,,n}, positive integer weights w i, i=,,n, positive integer m Q: find a partition of S into s.t. is minimized AUEB / DoI / TOPICS IN ALGORITHMS / Spring 27 / I. MILIS / 6 - PARTITIONS 3

Tree of reductions (partial) Cook s Th. " Π Î NP SAT 3-SAT MAX 2-SAT CLIQUE / IS / VC HP / HC 3-DM 3- GC TSP / Δ -TSP ZOE SUBSET SUM PARTITION - KNAPSACK SCHEDULING BIN PACKING Polynomial Γενίκευση του Π Πρόβλημα Π Ειδική περίπτωση του Π NP -complete ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II 4

Matching problems Matching in a graph G=(V,E): A subset M ÍE of edges s.t. no two edges in M have a vertex in common. MATCHING INSTANCE: A graph G=(V,E) QUESTION: Find a maximal/maximum/perfect matching in G Maximal: it is not a subset of another matching, i.e. it can not be extended Maximum: a matching of maximum cardinality, M, i.e. a maximum maximal matching Perfect: a matching of cardinality M =n/2 (it is defined only for graphs with even # of vertices) All matching problems are polynomial, even their weighted versions ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II 5

Matching problems PERFECT BIPARTITE MATCHING INSTANCE: Bipartite graph B=(B, G, E), with B = G =m, edges E Í B G QUESTION: Is there a subset of edges M Í Ε with M = m such that for each pair (b,g), (b',g') Î M it holds that b¹b', g¹g'? All bipartite matching problems are polynomial ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II 6

Matching problems A generalization of Bipartite matching: 3-DIMENSIONAL MATCHING (3-DM) INSTANCE: Sets B, G, P, with B = G = P =m, a set of triples T Í B G P (i.e. a tripartite graph) QUESTION: Is there a subset M Í T with M = m such that for each pair (b,g,p), (b',g',p') Î M it holds that b¹b', g¹g', p¹p'? 3-DM is NP-complete ( 3-SAT p 3-DM ) ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II 7

Zero-One Equations (ZOE) η διατύπωση ΕΙΣΟΔΟΣ: Σύστημα m εξισώσεων όπου α ij Î {,}, i m, j n ΕΡΩΤΗΣΗ: Υπάρχει λύση του συστήματος x,x 2,..., x n τ.ω. x i Î {,}, j n ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II 8 2 2 2 2 22 2 2 2 = + + + = + + + = + + + n mn m m n n n n x a x a x a x a x a x a x a x a x a!!!!

Zero-One Equations (ZOE) 2 η διατύπωση ΕΙΣΟΔΟΣ: - πίνακας Α διαστάσεων m x n ΕΡΩΤΗΣΗ: Υπάρχει - διάνυσμα x = [x,x 2,..., x n ] τ.ω. Α x= ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II 9 û ù ë é = û ù ë é û ù ë é 5 4 3 2 x x x x x

Zero-One Equations (ZOE) 3 η διατύπωση ΕΙΣΟΔΟΣ: - πίνακας Α διαστάσεων m x n ΕΡΩΤΗΣΗ: Υπάρχει υποσύνολο στηλών του Α που αν προστεθούν μεταξύ τους δίνουν σε όλες τις γραμμές ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II û ù ë é

3-DM p ZOE ZOE is NP-complete 3-DM: m αγόρια, m κορίτσια, m κατοικίδια, και n τριάδες Κατασκευάζουμε πίνακα Α με: 3m γραμμές (μία για κάθε αγόρι, κορίτσι, κατοικίδιο) n στήλες (μία για κάθε τριάδα) Κάθε στήλη/τριάδα έχει : - τρία στοιχεία (στις γραμμές αυτά που αντιστοιχούν στο αγόρι, κορίτσι, κατοικίδιο της τριάδας) - όλα τα άλλα στοιχεία Ένα 3-DM αντιστοιχεί σε m στήλες/τριάδες του πίνακα Α που αν προστεθούν μεταξύ τους δίνουν σε όλες τις γραμμές (οι γραμμές του Α είναι 3m και κάθε στήλη έχει τρία, άρα πρέπει να επιλεγούν m στήλες για να πάρουμε από την πρόσθεσή τους σε όλες τις γραμμές) ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II

3-DM p ZOE ZOE is NP-complete - παράδειγμα 5 τριάδες Al Bob Chet Alice Beatrice Carol Armadillo Bobcat Canary To 3-DM έχει απάντηση ΝΑΙ εάνν το ΖΟΕ έχει απάντηση ΝΑΙ ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II 2

Tree of reductions (partial) Cook s Th. " Π Î NP SAT 3-SAT MAX 2-SAT CLIQUE / IS / VC HP / HC 3-DM 3- GC TSP / Δ -TSP ZOE SUBSET SUM PARTITION - KNAPSACK SCHEDULING BIN PACKING Polynomial Γενίκευση του Π Πρόβλημα Π Ειδική περίπτωση του Π NP -complete ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II 3

Problems with numbers SUBSET SUM I: items S={,,n}, integer weights w i >, i=,,n, integer W> Q: is there A Í S s.t. = W? PARTITION I: items S={,,n}, integer weights w i >, i=,,n Q: is there A Í S s.t? - KNAPSACK I: items S={,,n}, weights w i >, values v i >, i=,,n, W>, all integers å Q: find A Í S s.t. w W and is maximized iîa i ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II 4

SUBSET-SUM is NP-complete ZOE SUBSET SUM w, w 2,, w n W Υπάρχει υποσύνολο στηλών που αν προστεθούν μεταξύ τους, κάνουν σε όλες τις γραμμές? Υπάρχει υποσύνολο αριθμών που αν προστεθούν μεταξύ τους, κάνουν W? Αναγωγή? ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II 5

MSB SUBSET-SUM is NP-complete ZOE 8 5 4 8 3 Θεωρούμε τις στήλες δυαδικούς ακεραίους (MSB πάνω) Υπάρχει υποσύνολο των ακεραίων 8, 5, 4, 8 που κάνει 2 = 3? NAI! Είναι η αναγωγή σωστή? SUBSET SUM w, w 2,, w n W Υπάρχει υποσύνολο αριθμών που αν προστεθούν μεταξύ τους, κάνουν W? ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II 6

SUBSET-SUM is NP-complete Είναι η αναγωγή σωστή? Δυστυχώς ΟΧΙ! Το άθροισμα δυαδικών αριθμών n bits μπορεί να ΕΙΝΑΙ 2 n - ΑΛΛΑ το άθροισμα των αντίστοιχων διανυσμάτων να ΜΗΝ ΕΙΝΑΙ. Π.χ.. γιατί Δυαδική πρόσθεση + + ¹ 5 6 2 = 3! Το SUBSET SUM έχει απάντηση ΝΑΙ αλλά το ΖΟΕ έχει απάντηση ΟΧΙ ΓΙΑΤΙ? ΚΡΑΤΟΥΜΕΝΟ! ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II 7

SUBSET-SUM is NP-complete Μπορούμε να σώσουμε την αναγωγή? ΝΑΙ! Σκεφτείτε κάθε στήλη του Α σαν ακέραιο στο σύστημα με βάση το n+! Τότε δεν θα υπάρχει κρατούμενο και η αναγωγή είναι σωστή: Το SUBSET SUM έχει απάντηση ΝΑΙ εάνν το ΖΟΕ έχει απάντηση ΝΑΙ ΑΛΛΑ ΠΡΟΣΟΧΗ!!! m W = n+ = Ο(n m ) και επίσης w i = Ο(n m ) Έστω Ι ένα στιγμιότυπο του ΖΟΕ και Ι το στιγμιότυπο του SUBSET SUM τότε Ι = Ο(exp( I ) Γι αυτό το SUBSET SUM έχει αλγόριθμο πολυπλοκότητας Ο(nW) (ψευτο-πολυωνυμικό) ΑΛΓΟΡΙΘΜΟΙ - ΑΝΟΙΞΗ 26 - Ι. ΜΗΛΗΣ 6 NP-COMPLETENESS II 8

Strong NP-completeness 3-SAT, CLIQUE, VC, IS, 3-GC, HP, HC, TSP: The reductions for all these problems use only small (polynomial) integers (names of nodes, indices, even in TSP we used only and 2) All these problems are strongly NP-complete ZOE p * SUBSET SUM: * This reduction creates exponentially large integers (w i s and W)! Τhe size of the SUBSET SUM s instance constructed is exponential in the size of the ZOE s instance! ( If I={n}, I = log n and I = {2 n }, I =n, then I =n=2 log n = 2 I ) SUBSET SUM is not strongly NP-complete but it is NP-complete. There is an O(nW) algorithm for SUBSET SUM SUBSET SUM is O(poly) if W is O(poly( I ))! AUEB / DoI / TOPICS IN ALGORITHMS / Spring 27 / I. MILIS / 6 - PARTITIONS 9

Subset Sum SUBSET SUM I: a set S={a, a 2,..., a n } of n positive integers and integer B Q: is there a subset A Í S such that å Î a i A i = B? BRUTE FORCE there are 2 n possible combinations of n items Go through all combinations; stop in the first one such that å a B ; otherwise report NO Complexity: O(n2 n i Î A i = ) Can we do better? AUEB / DoI / TOPICS IN ALGORITHMS / Spring 27 / I. MILIS / 6 - PARTITIONS 2

Subproblem - Recursive formula Let S i ={a, a 2,,a i }, Subset Sum - DP Subproblem: M (i, b), i n, b B, M (i, b): is there a subset A Í{a, a 2,..., a i } s.t.? If a i > b, then the the answer for M (i, b) is YES iff å Î there is a subset A Í S i- s.t. a b i A i = If a i b, then the the answer for M (i, b) is YES iff either there is a subset A Í S i- s.t. a or there is a subset A Í S i- s.t. å iîa If i=, then the answer is YES if B= and NO otherwise (Base case for i=) a å b i Î A i = å a i Î A i = b - ai i = b AUEB / DoI / TOPICS IN ALGORITHMS / Spring 27 / I. MILIS / 6 - PARTITIONS 2

Subset Sum - DP Recursive formula M ( i, b) = ìtrue ï ï ïfalse ï í ïm ( i -,b) ï ï ï M ( i -,b) ï î OR if i = and b = if i = and b if i ³ and if i ³ and i a M ( i -,b - a ) a i i > > b b AUEB / DoI / TOPICS IN ALGORITHMS / Spring 27 / I. MILIS / 6 - PARTITIONS 22

There are only nb subproblems Subset Sum - DP Fill a n x B Boolean matrix M[ i, b], i n, b B SubsetSum (S,n,B) M[,]= True; for b = to B do M[,b]=False; for i = to n do for b = to B do if a i > b then M[i,b]=M[i-,b] else M[i,b]= M[i-,b] OR M[i-,b-a i ] Complexity: O(nB) AUEB / DoI / TOPICS IN ALGORITHMS / Spring 27 / I. MILIS / 6 - PARTITIONS 23

Example: (4,,2,5), B=6 Subset Sum - DP b 2 3 4 5 6 i /a i /- T F F F F F F /4 T F F F T F F 2/ T T F F T T F 3/2 T T T T T T T 4/5 T T T T T T T if a i > b then M(i,b)=M(i-,b) else M(i,b)= M(i-,b) OR M(i-,b-a i ) AUEB / DoI / TOPICS IN ALGORITHMS / Spring 27 / I. MILIS / 6 - PARTITIONS 24

Subset Sum Complexity: O(nB) I = log a + log a 2 + + log a n + log B (n+) log B = O(n log B) Hence, O(nB) is O(exp(I)) NOT POLYNOMIAL But, N(I) =B, that is O(nB) is O(poly(N(I)) PSEUDO-POLYNOMIAL AUEB / DoI / TOPICS IN ALGORITHMS / Spring 27 / I. MILIS / - INTRO 25

Strong NP-completeness 3-SAT, CLIQUE, VC, IS, 3-GC, HP, HC, TSP: The reductions for all these problems use only small (polynomial) integers (names of nodes, indices, even in TSP we used only and 2) All these problems are strongly NP-complete ZOE p * SUBSET SUM: * This reduction creates exponentially large integers (w i s and W)! Τhe size of the SUBSET SUM s instance constructed is exponential in the size of the ZOE s instance! ( If I={n}, I = log n and I = {2 n }, I =n, then I =n=2 log n = 2 I ) SUBSET SUM is not strongly NP-complete but it is NP-complete. There is an O(nW) algorithm for SUBSET SUM SUBSET SUM is O(poly) if W is O(poly( I ))! AUEB / DoI / TOPICS IN ALGORITHMS / Spring 27 / I. MILIS / 6 - PARTITIONS 26

Strong NP-completeness and pseudo-polynomial algorithms A problem Π is strongly NP-complete if it remains NP-complete even if any instance of length I is restricted to contain integers at most O(poly( I )) or it remains NP-complete even if its instances are coded in unary Let N(I) be the largest number appearing in an instance of a problem An algorithm is a pseudo-polynomial one if it is polynomial in I and N(I) Unless P=NP, there is no pseudo-polynomial algorithm for strongly NPcomplete problems (next slide) For problems that are NP-complete, but not strongly NP-complete there is a pseudo-polynomial algorithm (usually a dynamic programming one) AUEB / DoI / TOPICS IN ALGORITHMS / Spring 27 / I. MILIS / 6 - PARTITIONS 27

Strong NP-completeness and pseudo-polynomial algorithms Let : I be an instance of a problem Π, of size I N(I) be the largest number in I p(n) be a polynomial Π p(n) be Π restricted to instances for which N(I) p( I ) We say that Π is strongly NP-complete if Π p(n) is NP-complete Th. Unless P=NP, there is no pseudo-polynomial algorithm for a strongly NP-complete problem Π Proof: Suppose that there exists such a pseudo-polynomial algorithm Q for Π Q solves any instance of Π in q( I, N(I) ) time; q: a polynomial Q solves Π p(n) in q( I, p( I ) ) time, that is polynomial in I P=NP! AUEB / DoI / TOPICS IN ALGORITHMS / Spring 27 / I. MILIS / 6 - PARTITIONS 28