Problem Set 9 Solutions

Similar documents
NP-Completeness : Proofs

Calculation of time complexity (3%)

Complete subgraphs in multipartite graphs

Finding Dense Subgraphs in G(n, 1/2)

Outline and Reading. Dynamic Programming. Dynamic Programming revealed. Computing Fibonacci. The General Dynamic Programming Technique

Maximizing the number of nonnegative subsets

Assortment Optimization under MNL

CS 331 DESIGN AND ANALYSIS OF ALGORITHMS DYNAMIC PROGRAMMING. Dr. Daisy Tang

College of Computer & Information Science Fall 2009 Northeastern University 20 October 2009

U.C. Berkeley CS294: Beyond Worst-Case Analysis Luca Trevisan September 5, 2017

A 2D Bounded Linear Program (H,c) 2D Linear Programming

find (x): given element x, return the canonical element of the set containing x;

Edge Isoperimetric Inequalities

Lecture Notes on Linear Regression

Lecture 10: May 6, 2013

Affine transformations and convexity

Example: (13320, 22140) =? Solution #1: The divisors of are 1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 20, 27, 30, 36, 41,

Dynamic Programming. Preview. Dynamic Programming. Dynamic Programming. Dynamic Programming (Example: Fibonacci Sequence)

arxiv: v2 [cs.ds] 1 Feb 2017

Min Cut, Fast Cut, Polynomial Identities

The Minimum Universal Cost Flow in an Infeasible Flow Network

First day August 1, Problems and Solutions

Structure and Drive Paul A. Jensen Copyright July 20, 2003

HMMT February 2016 February 20, 2016

Stanford University CS359G: Graph Partitioning and Expanders Handout 4 Luca Trevisan January 13, 2011

2.3 Nilpotent endomorphisms

U.C. Berkeley CS294: Spectral Methods and Expanders Handout 8 Luca Trevisan February 17, 2016

Every planar graph is 4-colourable a proof without computer

Lectures - Week 4 Matrix norms, Conditioning, Vector Spaces, Linear Independence, Spanning sets and Basis, Null space and Range of a Matrix

CHAPTER 17 Amortized Analysis

Kernel Methods and SVMs Extension

For now, let us focus on a specific model of neurons. These are simplified from reality but can achieve remarkable results.

n ). This is tight for all admissible values of t, k and n. k t + + n t

APPENDIX A Some Linear Algebra

and problem sheet 2

Module 9. Lecture 6. Duality in Assignment Problems

Module 3 LOSSY IMAGE COMPRESSION SYSTEMS. Version 2 ECE IIT, Kharagpur

Common loop optimizations. Example to improve locality. Why Dependence Analysis. Data Dependence in Loops. Goal is to find best schedule:

Problem Set 6: Trees Spring 2018

Cluster Validation Determining Number of Clusters. Umut ORHAN, PhD.

= z 20 z n. (k 20) + 4 z k = 4

Exercises. 18 Algorithms

princeton univ. F 17 cos 521: Advanced Algorithm Design Lecture 7: LP Duality Lecturer: Matt Weinberg

= = = (a) Use the MATLAB command rref to solve the system. (b) Let A be the coefficient matrix and B be the right-hand side of the system.

Math 261 Exercise sheet 2

Capacity Constraints Across Nests in Assortment Optimization Under the Nested Logit Model

arxiv: v3 [cs.dm] 7 Jul 2012

On the Multicriteria Integer Network Flow Problem

Graph Reconstruction by Permutations

NUMERICAL DIFFERENTIATION

U.C. Berkeley CS294: Beyond Worst-Case Analysis Handout 6 Luca Trevisan September 12, 2017

Week 2. This week, we covered operations on sets and cardinality.

THE ARIMOTO-BLAHUT ALGORITHM FOR COMPUTATION OF CHANNEL CAPACITY. William A. Pearlman. References: S. Arimoto - IEEE Trans. Inform. Thy., Jan.

Dynamic Programming 4/5/12. Dynamic programming. Fibonacci numbers. Fibonacci: a first attempt. David Kauchak cs302 Spring 2012

Chapter 5. Solution of System of Linear Equations. Module No. 6. Solution of Inconsistent and Ill Conditioned Systems

Annexes. EC.1. Cycle-base move illustration. EC.2. Problem Instances

20. Mon, Oct. 13 What we have done so far corresponds roughly to Chapters 2 & 3 of Lee. Now we turn to Chapter 4. The first idea is connectedness.

Errors for Linear Systems

Complex Numbers Alpha, Round 1 Test #123

Vickrey Auction VCG Combinatorial Auctions. Mechanism Design. Algorithms and Data Structures. Winter 2016

Finding Primitive Roots Pseudo-Deterministically

Introduction to Vapor/Liquid Equilibrium, part 2. Raoult s Law:

Notes on Frequency Estimation in Data Streams

Singular Value Decomposition: Theory and Applications

Lecture 20: Lift and Project, SDP Duality. Today we will study the Lift and Project method. Then we will prove the SDP duality theorem.

Chapter Newton s Method

Lecture 4. Instructor: Haipeng Luo

Lecture 2: Gram-Schmidt Vectors and the LLL Algorithm

8.4 COMPLEX VECTOR SPACES AND INNER PRODUCTS

More metrics on cartesian products

Case A. P k = Ni ( 2L i k 1 ) + (# big cells) 10d 2 P k.

Linear, affine, and convex sets and hulls In the sequel, unless otherwise specified, X will denote a real vector space.

Lecture 4: November 17, Part 1 Single Buffer Management

Lecture 5 Decoding Binary BCH Codes

THE CHINESE REMAINDER THEOREM. We should thank the Chinese for their wonderful remainder theorem. Glenn Stevens

Basic Regular Expressions. Introduction. Introduction to Computability. Theory. Motivation. Lecture4: Regular Expressions

Partitioning Graphs of Supply and Demand

Spectral Graph Theory and its Applications September 16, Lecture 5

An Interactive Optimisation Tool for Allocation Problems

Lecture 12: Discrete Laplacian

Design and Analysis of Algorithms

Foundations of Arithmetic

Math1110 (Spring 2009) Prelim 3 - Solutions

Problem Do any of the following determine homomorphisms from GL n (C) to GL n (C)?

Polynomial Regression Models

2E Pattern Recognition Solutions to Introduction to Pattern Recognition, Chapter 2: Bayesian pattern classification

MATH 5707 HOMEWORK 4 SOLUTIONS 2. 2 i 2p i E(X i ) + E(Xi 2 ) ä i=1. i=1

Discrete Mathematics

A new construction of 3-separable matrices via an improved decoding of Macula s construction

REAL ANALYSIS I HOMEWORK 1

Grover s Algorithm + Quantum Zeno Effect + Vaidman

Math 426: Probability MWF 1pm, Gasson 310 Homework 4 Selected Solutions

The Expectation-Maximization Algorithm

18.781: Solution to Practice Questions for Final Exam

First Year Examination Department of Statistics, University of Florida

CS : Algorithms and Uncertainty Lecture 17 Date: October 26, 2016

ECE559VV Project Report

Tornado and Luby Transform Codes. Ashish Khisti Presentation October 22, 2003

The L(2, 1)-Labeling on -Product of Graphs

O-line Temporary Tasks Assignment. Abstract. In this paper we consider the temporary tasks assignment

Transcription:

Desgn and Analyss of Algorthms May 4, 2015 Massachusetts Insttute of Technology 6.046J/18.410J Profs. Erk Demane, Srn Devadas, and Nancy Lynch Problem Set 9 Solutons Problem Set 9 Solutons Ths problem set s due at 11:59pm on Thursday, Aprl 30, 2015. Exercse 9-1. Read CLRS, Chapter 35. Exercse 9-2. Exercse 35.2-3. Exercse 9-3. Exercse 35.4-2. Exercse 9-4. Read Prof. Demane s notes on fxed-parameter algorthms. Problem 9-1. Knapsack [25 ponts] In the Knapsack problem, we are gven a set A = {a 1,..., a n } of tems, where each a has a specfed postve nteger sze s and a specfed postve nteger value v. We are also gven a postve nteger knapsack capacty B. Assume that s B for every. The problem s to fnd a subset of A whose total sze s at most B and for whch the total value s maxmzed. In ths problem, we wll consder approxmaton algorthms to solve the Knapsack problem. Notaton: For any subset S of A, we wrte s S for the total of all the szes n S and v S for the total of all the values n S. Let Opt denote an optmal soluton to the problem. (a) [5 ponts] Consder the followng greedy algorthm Alg 1 to solve the Knapsack problem: Order all the tems a n non-ncreasng order of ther densty, whch s the rato of value to sze, v s. Make a sngle pass through the lst, from hghest to lowest densty. For each tem encountered, f t stll fts, nclude t, otherwse exclude t. Prove that algorthm Alg 1 does not guarantee any constant approxmaton rato. That s, for any postve nteger k, there s an nput to the algorthm for whch the total value of the set of tems returned by the algorthm s at most v Opt. k Soluton: Fx any k. Consder the two-tem nput lst a 1, a 2, where v 1 = 2, s 1 = 1, v 1 v v 2 2 = 2k, and s k = 2k, wth knapsack capacty B = 2k. Snce = 2 and = 1, s 1 s 2 Alg 1 consders the tems n order a 1, a 2, and ncludes a 1 and excludes a 2. The total value acheved s only 2, but the largest achevable total value s 2k.

2 Problem Set 9 Solutons (b) [7 ponts] Consder the followng algorthm Alg 2. If the total sze of all the tems s B, then nclude all the tems. If not, then order all the tems n non-ncreasng order of ther denstes. Wthout loss of generalty, assume that ths orderng s the same as the orderng of the tem ndces. Fnd the smallest ndex n the ordered lst such that the total sze of the frst tems exceeds B (.e., 1 1 s j > B, but s j B). If v > v j, then return {a }. Otherwse, return {a 1,..., a 1 }. Prove that Alg 2 always yelds a 2-approxmaton to the optmal soluton. Soluton: We know that fractonal knapsack problem can be solved va greedy algorthm; the optmal soluton for fractonal knapsack problem takes frst 1 tems, and takes some fracton α of tem. That s, fractonal knapsack optmal soluton v fopt s 1 v fopt = v j + αv. Snce every knapsack problem s a vald fractonal knapsack problem, we know that v Opt v fopt. Now consder the soluton output by Alg 2. 1 1 v fopt max( v j, v ) max( v j, αv ), 2 because at least one of the two terms needs to be larger than half of v fopt. Therefore, we have 1 v Opt v fopt 2 max( v j, v ), whch shows that Alg 2 s a 2-approxmaton algorthm. Soluton: Ths s an alternate soluton. Assume for contradcton that there s some nput nstance for whch Alg 2 does not acheve a 2-approxmaton to the optmal soluton. Then for as specfed n the 1 algorthm, the maxmum of v and v j s strctly less than v Opt. That s, both 2 1 v Opt v and v j are strctly less than. Then v j < v Opt. We also know that 2 s j > B. Let C = {a 1,..., a } Opt, D = Opt {a 1,..., a }, and E = {a 1,..., a } Opt. We know that v C = v j v E, and v D = v Opt v E. Snce v j < v Opt, we now have that v C < v D. We also know that s C > s D, snce s j > B and s D B. < v D Therefore, the densty of C s strctly less than the densty of D (.e., v C ). s C s D

Problem Set 9 Solutons 3 Now recall that the denstes of {a 1,..., a n } are non-ncreasng. Consder j v s j j j:v C (v j s v s j ) = j. We know that v j j:v j C s s j s j s v C v v D v j v C v v D s C s s D s j s C s s D j j:v j C v j j:v j C s j v for a j C, and thus v j s v s j > 0. Ths mples that, and smlar argument holds for. Therefore,. Ths contradcts our result from the prevous paragraph that says v C < v D, and Alg 2 must be a 2-approxmaton. s C s D (c) [5 ponts] Let A = {a 1,..., a n } be the nput ordered arbtrarly, and V be the largest value for any tem; then nv s an upper bound on the total value that could be acheved by any soluton. For every {1,..., n} and v {1,..., nv }, defne S,v to be the smallest total sze of a subset of {a 1,..., a } whose total value s exactly v; S,v = f no such subset exsts. Gve a dynamc programmng algorthm Alg 3 to solve Knapsack exactly. Specfcally, gve a recurrence to compute all values of S,v, and explan how to use ths to solve the Knapsack problem. Analyze ts tme complexty. Soluton: S 1,v = s 1 f v 1 = v, and = otherwse. For 1 n 1: S +1,v = mn{s,v, s +1 + S,v v+1 } f v +1 v, S,v otherwse. The computaton of all of these values takes tme O(n 2 V ). As usual for dynamc programmng algorthms, we can add bookkeepng to calculate the actual subsets as we go along. The maxmum total value achevable s max vls n,v B. The fnal output s a subset of A whose total value s ths maxmum. Snce the tme complexty O(n 2 V ) depends lnearly on V, whch s represented n bnary n the nput to the problem, Alg 3 s a pseudo-polynomal-tme algorthm. (d) [8 ponts] Fnally, we develop Alg 4, whch s a Fully Polynomal Tme Approxmaton Scheme (FPTAS) for Knapsack. The dea s to use an exact dynamc programmng algorthm lke the one n Part (c), but nstead of usng the gven (possbly large) values for the tems, we use versons of the gven values that are sutably scaled and rounded down. As n Part (c), order A = {a 1,..., a n } arbtrarly, and let V be the largest value for any tem. For any ε, 0 < ε < 1, Alg 4 behaves as follows: = l( v For each tem a wth value v, defne a scaled value v )( n)j. V ε Usng these scaled values (and the gven szes), run Alg 3 and output the set C of tems that t returns. Prove that Alg 4 s a FPTAS for Knapsack. Soluton:

4 Problem Set 9 Solutons By Part (c), the runnng tme of the algorthm s O(n 2 ( V )( n ) ) = V ε O(n2 n ), whch ε s polynomal n n and 1. ε It remans to show that the set C returned by the algorthm has total value v C (1 ε)v Opt. Let K denote εv, so each v = v v n. It follows that K K v K. Consderng all the elements of O, we get v O pt K v Opt nk. Now consder the set C that s returned by the dynamc programmng step. We have that v C Kv C. Also, snce the set C s optmal n terms of the scaled values, we have v C v O pt. Therefore, we have: v C Kv C Kv O pt v Opt nk = v Opt εv v Opt εv Opt = (1 ε)v Opt. Ths s as needed. Problem 9-2. Fxed-Parameter Algorthms [25 ponts] We consder the Tournament Edge Reversal problem. Defne a tournament to be a drected graph T = (V, E) such that, for every par of vertces u, v V, exactly one of (u, v) and (v, u) s n E. Furthermore, defne a cycle cover to be a set A E of drected edges of a tournament T such that, every drected cycle of T contans at least one edge from A. (a) [5 ponts] Let a mnmal cycle cover of T be a cycle cover wth the least number of edges. Prove that reversng all the edges of a mnmal cycle cover A turns T nto an acyclc tournament. (Hnt: Any edge e A must be the only edge n A on some drected cycle of T.) Soluton: Let T be the new tournament. Suppose for contradcton that T contans a cycle C. Let F be the set of edges of C that were obtaned by reversng the edges of A, and let F be ther reversals, whch are edges n T. For each e F, let C e be a drected cycle of T that e covers. From the hnt, we know e s the only edge n A that s also n C e. Now we can construct a cycle C n T, consstng entrely of edges of T that dd not get reversed: Include all reverse of edges n C F (whch are vald edges n T ), and for each e C F, nclude all the edges of C e except for e. Ths yelds a cycle C n T that contans no edges n A, whch s a contradcton. In the Tournament Edge Reversal problem, we are gven a tournament T and a postve nteger k, and the objectve s to decde whether T has a cycle cover of sze at most k. (b) [15 ponts] Show that ths problem has a kernel wth at most k 2 + 2k vertces. (Hnt: Defne a trangle to be a drected cycle of length 3. Consder the number of tmes that a node or an edge appears n dfferent trangles.) Soluton:

Problem Set 9 Solutons 5 Part (a) mples that a tournament T has a cycle cover of sze at most k f and only f t can be turned nto an acyclc tournament by reversng drectons of at most k edges. We wll use ths characterzaton for the kernel. We gve two smple reducton rules: Rule 1: If an edge e s contaned n k + 1 trangles, then reverse e and reduce k by 1. Ths rule s safe because f we do not reverse e, we must reverse at least one edge from each of k + 1 trangles contanng e. Thus e belongs to every cycle cover of sze k. Rule 2: If a vertex v s not contaned n any trangle, then delete v from T. To see why ths s safe, let X be the set of vertces u such that T contans the edge (v, u) (the outgong neghbors of v), and let Y be the set of vertces u such that T contans the edge (u, v) (the ncomng neghbors of v). X and Y partton the vertces n V {v}. Snce v s not contaned n any trangle, there s no edge from X to Y. Thus, every drected cycle n T s ether wholly contaned wthn the subgraph nduced by X or the subgraph nduced by Y. Therefore, removng v and ts ncdent edges from T does not affect the sze of the mnmum cycle cover. Thus, startng wth nstance (T ; k) = (T 0 ; k 0 ), we apply our reducton rules repeatedly untl they cannot be appled any longer, obtanng a sequence of equvalent nstances (T 1 ; k 1 ), (T 2 ; k 2 ),..., (T m ; k m ) = (T ; k ), where nether Rule s applcable to the fnal nstance (T ; k ). Clam: If T has a cycle cover A of sze k, then T has at most k (k + 2) vertces. Proof of clam: Snce Rule 2 s not applcable, every vertex of T s n a trangle, whch must contan some edge n A. Snce Rule 1 s not applcable, for every edge e A, there are at most k vertces other than e s endponts that are n trangles contanng e. Snce A k, t follows that T has at most k (k + 2) vertces. Thus, after reducng, we consder the fnal nstance (T, k ). If T has more than k (k + 2) vertces, then t cannot have a cycle cover of sze k, and s a no-nstance. By equvalence, (T, k) s also a no-nstance. We return no n ths case. Otherwse, we get the desred kernel wth at most k 2 + 2k vertces. (c) [5 ponts] Obtan a FPT algorthm for the Tournament Edge Reversal problem. Soluton: Gven an nstance (T, k) for the Tournament Edge Reversal problem, use the algorthm from Part (b) to ether determne that (T, k) s a no-nstance or obtan a kernel (T, k ) where k k and T has at most k (k + 2) vertces. In the former case, answer no. In the latter case, run any algorthm wth runnng tme g(k ), for any functon g, to solve the Tournament Edge Reversal problem on (T, k ). Return the result as the answer. To reduce the problem, we have to check for all trangles, and check membershp of all edges and vertces n the trangles. For vertces, to check all trangles, t takes O( ( ) V 2 ) per vertex. For edges, t takes V per edge. Each reducton step thus takes

6 Problem Set 9 Solutons O( V 3 + V E )). There are at most V +E reducton steps snce each step removes an edge or a vertex. In total, reducton takes O( V 4 + V 3 E + V 2 E + V E 2 ). Snce O( E ) = O( V 2 ) n tournaments, ths s O( V 5 ). To fnd the mnmum cycle cover, one soluton s to check all possble subsets of edges n T. There are O(2 k/2 (k / +2) 2 ) subsets, and for each subset we need to run a cycle fndng algorthm, such as DFS, to ensure all cycles are covered. Therefore, the fnal tme complexty s O( V 5 )+2 O(k4).

MIT OpenCourseWare http://ocw.mt.edu 6.046J / 18.410J Desgn and Analyss of Algorthms Sprng 2015 For nformaton about ctng these materals or our Terms of Use, vst: http://ocw.mt.edu/terms.