Design and Analysis of Algorithms May 12, 2011 Massachusetts Institute of Technology. Practice Final Exam. Problem Title Points Parts Grade Initials

Similar documents
Design and Analysis of Algorithms April 16, 2015 Massachusetts Institute of Technology Profs. Erik Demaine, Srini Devadas, and Nancy Lynch Quiz 2

Design and Analysis of Algorithms March 12, 2015 Massachusetts Institute of Technology Profs. Erik Demaine, Srini Devadas, and Nancy Lynch Quiz 1

Introduction to Algorithms March 10, 2010 Massachusetts Institute of Technology Spring 2010 Professors Piotr Indyk and David Karger Quiz 1

Chapter 34: NP-Completeness

Data Structures and Algorithms (CSCI 340)

SAT, Coloring, Hamiltonian Cycle, TSP

CS/COE

FINAL EXAM PRACTICE PROBLEMS CMSC 451 (Spring 2016)

University of Toronto Department of Electrical and Computer Engineering. Final Examination. ECE 345 Algorithms and Data Structures Fall 2016

Outline. 1 NP-Completeness Theory. 2 Limitation of Computation. 3 Examples. 4 Decision Problems. 5 Verification Algorithm

Algorithms Design & Analysis. Approximation Algorithm

ECS122A Handout on NP-Completeness March 12, 2018

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science ALGORITHMS FOR INFERENCE Fall 2014

} } } Lecture 23: Computational Complexity. Lecture Overview. Definitions: EXP R. uncomputable/ undecidable P C EXP C R = = Examples

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms

Lecture 12 Scribe Notes

Tractable & Intractable Problems

Hamiltonian Cycle. Hamiltonian Cycle

NP and Computational Intractability

Data Structures in Java

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

July 18, Approximation Algorithms (Travelling Salesman Problem)

NP-Completeness. Until now we have been designing algorithms for specific problems

NP-Complete Problems. More reductions

Algorithms. NP -Complete Problems. Dong Kyue Kim Hanyang University

University of Washington March 21, 2013 Department of Computer Science and Engineering CSEP 521, Winter Exam Solution, Monday, March 18, 2013

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

NP-Complete Problems and Approximation Algorithms

Quiz 3. Please write your name in the upper corner of each page. Problem Points Grade. Total 100 Q3-1

VIII. NP-completeness

University of New Mexico Department of Computer Science. Final Examination. CS 362 Data Structures and Algorithms Spring, 2007

Limits to Approximability: When Algorithms Won't Help You. Note: Contents of today s lecture won t be on the exam

Algorithms, Lecture 3 on NP : Nondeterminis7c Polynomial Time

CSCE 750 Final Exam Answer Key Wednesday December 7, 2005

NP-completeness. Chapter 34. Sergey Bereg

3130CIT Theory of Computation

CS 170 Algorithms Spring 2009 David Wagner Final

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

Quiz 1 Date: Monday, October 17, 2016

Econ 172A, Fall 2012: Final Examination (I) 1. The examination has seven questions. Answer them all.

UCSD CSE 21, Spring 2014 [Section B00] Mathematics for Algorithm and System Analysis

CS 583: Algorithms. NP Completeness Ch 34. Intractability

CS1800 Discrete Structures Spring 2018 February CS1800 Discrete Structures Midterm Version A

Unit 1A: Computational Complexity

Computational Intractability 2010/4/15. Lecture 2

Lecture 15 - NP Completeness 1

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

from notes written mostly by Dr. Matt Stallmann: All Rights Reserved

1. Introduction Recap

8.5 Sequencing Problems

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

Graph Theory and Optimization Computational Complexity (in brief)

15.083J/6.859J Integer Optimization. Lecture 2: Efficient Algorithms and Computational Complexity

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

NP-Completeness. ch34 Hewett. Problem. Tractable Intractable Non-computable computationally infeasible super poly-time alg. sol. E.g.

Graduate Algorithms CS F-21 NP & Approximation Algorithms

CS 70 Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand Midterm 1 Solutions

Examination paper for TDT4120 Algorithms and Data Structures

Technische Universität München, Zentrum Mathematik Lehrstuhl für Angewandte Geometrie und Diskrete Mathematik. Combinatorial Optimization (MA 4502)

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

NP-Complete Reductions 1

NP-Complete Reductions 2

CSI 4105 MIDTERM SOLUTION

Topics in Complexity Theory

CS 301: Complexity of Algorithms (Term I 2008) Alex Tiskin Harald Räcke. Hamiltonian Cycle. 8.5 Sequencing Problems. Directed Hamiltonian Cycle

ABHELSINKI UNIVERSITY OF TECHNOLOGY

COMP Analysis of Algorithms & Data Structures

NP Completeness and Approximation Algorithms

Polynomial-Time Reductions

Design and Analysis of Algorithms

Exam EDAF May 2011, , Vic1. Thore Husfeldt

CS 188 Introduction to Fall 2007 Artificial Intelligence Midterm

Optimization Prof. A. Goswami Department of Mathematics Indian Institute of Technology, Kharagpur. Lecture - 20 Travelling Salesman Problem

NP-Completeness Theory

Branch-and-Bound. Leo Liberti. LIX, École Polytechnique, France. INF , Lecture p. 1

Fall 2016 Test 1 with Solutions

Algorithms and Complexity Theory. Chapter 8: Introduction to Complexity. Computer Science - Durban - September 2005

Final Examination. Your name: Circle the name of your Tutorial Instructor: David Hanson Jelani Sayan

CS 350 Algorithms and Complexity

Exam EDAF August Thore Husfeldt

Algorithm Design Strategies V

4/12/2011. Chapter 8. NP and Computational Intractability. Directed Hamiltonian Cycle. Traveling Salesman Problem. Directed Hamiltonian Cycle

Essential facts about NP-completeness:

More NP-Complete Problems

Problem Complexity Classes

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

Lecture 4: NP and computational intractability

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: NP-Completeness I Date: 11/13/18

Polynomial-time Reductions

UNIVERSITY OF CALIFORNIA, RIVERSIDE

Complexity, P and NP

Discrete Optimization 2010 Lecture 8 Lagrangian Relaxation / P, N P and co-n P

Turing Machines and Time Complexity

More on NP and Reductions

University of New Mexico Department of Computer Science. Final Examination. CS 561 Data Structures and Algorithms Fall, 2006

Lecture 18: P & NP. Revised, May 1, CLRS, pp

Problem Set 3 Due: Wednesday, October 22nd, 2014

Instructions. Do not open your test until instructed to do so!

Today: NP-Completeness (con t.)

Algorithms Re-Exam TIN093/DIT600

Transcription:

Design and Analysis of Algorithms May 12, 2011 Massachusetts Institute of Technology 6.046J/18.410J Profs. Dana Moshkovitz and Bruce Tidor Practice Final Exam Practice Final Exam Do not open this quiz booklet until you are directed to do so. Read all the instructions first. The quiz contains 6 problems, several with multiple parts. You have 180 minutes to earn 120 points. This quiz booklet contains 15 pages, including this one, and a sheet of scratch paper which can be detached. This quiz is closed book. You may use two double sided Letter (8 1 2 11 ) or A4 crib sheets. No calculators or programmable devices are permitted. Cell phones must be put away. Write your solutions in the space provided. If you run out of space, continue your answer on the back of the same sheet and make a notation on the front of the sheet. Do not waste time deriving facts that we have studied. It is sufficient to cite known results. Do not spend too much time on any one problem. Generally, a problem s point value is an indication of how many minutes to spend on it. Show your work, as partial credit will be given. You will be graded not only on the correctness of your answer, but also on the clarity with which you express it. Please be neat. Good luck! Problem Title Points Parts Grade Initials 0 Name 1 15 1 True or False 44 11 2 P, NP & Friends 10 1 3 Taming MAX-CUT 10 3 4 Spy Games 10 2 5 Lots of Spanning trees 25 5 6 Traveling with the salesman 20 3 Total 120 Name:

6.046J/18.410J Practice Final Exam Name 2 Problem 0. Name. [1 point] Write your name on every page of this exam booklet! Don t forget the cover. Problem 1. True or False. [44 points] (11 parts) Circle T or F for each of the following statements to indicate whether the statement is true or false, respectively, and briefly explain why. Your justification is worth more points than your true-or-false designation. (a) T F [4 points] If problemacan be reduced to 3SAT via a deterministic polynomialtime reduction, and A NP, then A is NP-complete. Solution: False. We need to reduce in the other direction (reduce an NP-hard problem to A). (b) T F [4 points] Let G = (V,E) be a flow network, i.e., a weighted directed graph with a distinguished source vertex s, a sink vertex t, and non-negative capacity c(u,v) for every edge(u,v) ine. Suppose you find ans-t cutc which has edges e 1,e 2,...,e k and a capacityf. Suppose the value of the maximums-t flow ing is f. Now leth be the flow network obtained by adding 1 to the capacity of each edge in C. Then the value of the maximums-t flow in H isf +k. Solution: False. There could be multiple min-cuts. Consider the graph s-v-t where the edges have capacity 1; either edge in itself is a min-cut, but adding capacity to that edge alone does not increase the max flow.

6.046J/18.410J Practice Final Exam Name 3 (c) T F [4 points] Let A and B be optimization problems where it is known that A reduces to B in polynomial time. Additionally, it is known that there exists a polynomial-time 2-approximation for B. Then there must exist a polynomialtime 2-approximation fora. Solution: False. approximation factor is not (necessarily) carried over in polytime reduction. See e.g. set cover vs. vertex cover. (d) T F [4 points] There exists a polynomial-time 2-approximation algorithm for the general Traveling Salesman Problem. Solution: False, assuming P = NP. There is an approximation algorithm in the special case where the graph obeys the triangle inequality, but we don t know of one in general.

6.046J/18.410J Practice Final Exam Name 4 (e) T F [4 points] If we use a max-queue instead of a min-queue in Kruskal s MST algorithm, it will return the spanning tree of maximum total cost (instead of returning the spanning tree of minimum total cost). (Assume the input is a weighted connected undirected graph.) Solution: True. The proof is essentially the same as for the usual Kruskal s algorithm. Alternatively, this is equivalent to negating all the edge weights and running Kruskal s algorithm. (f) T F [4 points] A randomized algorithm for a decision problem with one-sided-error and correctness probability 1/3 (that is, if the answer is YES, it will always output YES, while if the answer isno, it will outputno with probability1/3) can always be amplified to a correctness probability of99%. Solution: True. Since the error is one-sided, it in fact suffices for the correctness probability to be any constant> 0. We can then repeat it, say,k times, and output NO if we ever see ano, andyes otherwise. Then, if the correct answer isyes, all k repetitions of our algorithm will output YES, so our final answer is also YES, and if the correct answer is NO, each of our k repetitions has a 1/3 chance of returning NO, in which case our final answer is, correctly, NO, with probability 1 (2/3) k, sok = log 3/2 100 repetitions suffice.

6.046J/18.410J Practice Final Exam Name 5 (g) T F [4 points] Suppose that a randomized algorithm A has expected running time Θ(n 2 ) on any input of sizen. Then it is possible for some execution ofato take Ω(3 n ) time. Solution: True. Imagine a scenario where the runtime ofaisθ(3 n ) with probabilityn 3 n, andθ(n 2 ) otherwise. It is apparent that the expected run time ofa is Θ(n 2 ). But, with non-zero probability some execution may takeω(3 n ) time. (h) T F [4 points] Building a heap on n elements takes Θ(n lg n) time. Solution: False. It can be done ino(n) time.

6.046J/18.410J Practice Final Exam Name 6 (i) T F [4 points] We can evaluate a polynomial of degree-boundnat any set ofnpoints in O(nlgn) time. Solution: False. Evaluating a polynomial of degree-bound n at any (arbitrary) set of n points takes O(nlg 2 n) time. For details, one may refer to problem 2 of pset 8. (j) T F [4 points] Suppose that you have two deterministic online algorithms, A 1 and A 2, with a competitive ratios c 1 and c 2 respectively. Consider the randomized algorithm A that flips a fair coin once at the beginning; if the coin comes up heads, it runs A 1 from then on; if the coin comes up tails, it runs A 2 from then on. Then the expected competitive ratio ofa is at leastmin{c 1,c 2 }. Solution: False. Suppose the problem is to guess which of two cups holds the bean. Algorithm A 1 checks left cup then right cup and has competitive ratio c 1 = 2. Algorithm A 2 checks right cup then left cup and has competitive ratio c 2 = 2. The randomized algorithm has competitive ratio c = 0.5 2+0.5 1 = 1.5 < min{c 1,c 2 }

6.046J/18.410J Practice Final Exam Name 7 Problem 2. Taming Max-Cut [10 points] A CUT, in a graph G = (V, E), is a partition of V into two non-intersecting sets A,B. An edge is said to be in the cut if one of its end points is in A and the other is in B. In the MAX-CUT problem, the objective is to maximize the number of edges in the cut. We intend to design an approximation scheme for MAX-CUT. Consider the following scheme. Every vertexv V is assigned to A,B uniformly at random. (a) What is the probability thate E is in the cut? Solution: With probability 1/2, one vertex of e is assigned to a set different from the other. Thus, the probability thateis in the cut is1/2. (b) What is the expected number of edges in the cut? Solution: Use an indicator variable for every edge with probability of success(being in the cut) being 1/2. Since, the variables are identical and independent, each experiment is a Bernouli experiement. The expected number of successes among the E Bernouli trails is E /2. Thus, the expected number of edges in the cut is E /2.

6.046J/18.410J Practice Final Exam Name 8 (c) Conclude that the randomized scheme presented above is a 2-approximation to the MAX-CUT. Solution: The maximum number of edges in the cut is E. The randomized scheme has no more than2times worse than the optimum in expectation. Problem 3. Lots of Spanning Trees. (5 parts) [25 points] Let G = (V, E) be a connected undirected graph with edge-weight functionw : E Ê. Let w min and w max denote the minimum and maximum weights, respectively, of the edges in the graph. Do not assume that the edge weights ingare distinct or nonnegative. The following statements may or may not be correct. In each case, either prove the statement is correct or give a counterexample if it is incorrect. (a) If the graph G has more than V 1 edges and there is a unique edge having the largest weightw max, then this edge cannot be part of any minimum spanning tree. Solution: False. This heavy edge could be the only edge connecting some vertex to a graph and thus must be included in the MST.

6.046J/18.410J Practice Final Exam Name 9 (b) Any edgeewith weightw min, must be part of some MST. Solution: True. In some ordering of the edges by increasing weight,ewill be the first, thus included in the tree constructed by the Kruskal s algorithm. Any tree constructed by the Kruskal s algorithm is an MST. (c) If G has a cycle and there is unique edge e which has the minimum weight on this cycle, thenemust be part of every MST. Solution: False. Consider the graph of a tetrahedron where the three edges of the base triangle have weights 2, 3, 4 and the three edges connecting the peak to the base all have weight 1. Then the MST is composed of those latter three edges and does not include the edge with weight2in the bottom cycle.

6.046J/18.410J Practice Final Exam Name 10 (d) If the edge e is not part of any MST of G, then it must be the maximum weight edge on some cycle in G. Solution: True. Take any MST T. Since e is not part of it, e must complete some cycle in T. e must be the heaviest edge on that cycle. Otherwise a smaller weight tree could be constructed by swapping the heavier edge on the cycle with e and thus T cannot be MST. (e) Suppose the edge weights are nonnegative. Then the shortest path between two vertices must be part of some MST. Solution: False. Consider a simple triangle with sides 1, 1, 1.5. The MST is composed of the two lighter edges while the longer edge is the shortest path between two vertices.

6.046J/18.410J Practice Final Exam Name 11 Problem 4. Traveling with the salesman. [20 points] In the traveling-salesman problem, a salesman must visitncities. Modeling the problem as a complete graph onnvertices, we can say that the salesman wishes to make a tour or a hamiltonian cycle, visiting each city exactly only once and finishing at the city he starts from. The salesman incurs a nonnegative integer cost c(i, j) to travel from cityito cityj, and the salesman wishes to make a tour whose total cost is minimum, where the total cost is the sum of the individual costs along the edges of the tour. (a) Formulate the traveling salesman problem as a language. TSP = Solution: { A complete graph of n vertices with non-negative edge TSP = < n,c,k > } weightschas a hamiltonian cycle of cost at mostk. (b) Prove that TSP NP. Solution: An instance < n,c,k > can be verified to be in TSP given a tour (a permutation of indices) as the certificate. The tour can be easily checked in poly-time to traverse every node exactly once and have a satisfying total cost.

A hamiltonian cycle in a graph is a cycle that visits every vertex exactly once. Define the language HAM-CYCLE = {< G >: there is a hamiltonian cycle in G}. (c) Assuming that HAM-CYCLE is complete for the class NP, prove that TSP is NP- Complete. Solution: To prove that TSP is NP-Hard, we show the reduction HAM-CYCLE p TSP. Given a graph G = (V,E) we define edge costs (in the complete graph) c(u,v) = 0 if (u,v) E and c(u,v) = 1 otherwise. If G has a hamiltonian cycle, then that cycle is also a tour of cost 0 in the complete graph with costs c, so < n,c,0 > TSP. For the converse, if there is a tour in the complete graph with cost 0, then it must traverse edges that are present in G, so this tour is also a hamiltonian cycle ing. TSP is NP-Complete because it is both in NP and NP-Hard.

SCRATCH PAPER

MIT OpenCourseWare http://ocw.mit.edu 6.046J / 18.410J Design and Analysis of Algorithms Spring 2012 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.