Homework 3: Solution 1:

Similar documents
NP-complete? NP-hard? Some Foundations of Complexity. Prof. Sven Hartmann Clausthal University of Technology Department of Informatics

Midterm Practice Problems

CMPSCI611: Approximating MAX-CUT Lecture 20

Outline. NP-completeness. When is a problem easy? When is a problem hard? Today. Euler Circuits

Page 1. CSCE 310J Data Structures & Algorithms. CSCE 310J Data Structures & Algorithms. P, NP, and NP-Complete. Polynomial-Time Algorithms

Why? A central concept in Computer Science. Algorithms are ubiquitous.

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

Computer Algorithms. NP-Complete Problems. CISC 4080 Yanjun Li

Lecture 7: NP-Complete Problems

Problem Set 7 Solutions

CSC 373: Algorithm Design and Analysis Lecture 16

Graph Theory Problems and Solutions

3. Mathematical Induction

On the Unique Games Conjecture

5.1 Bipartite Matching

Complexity Theory. IE 661: Scheduling Theory Fall 2003 Satyaki Ghosh Dastidar

Reductions & NP-completeness as part of Foundations of Computer Science undergraduate course

Tutorial 8. NP-Complete Problems

Network Flow I. Lecture Overview The Network Flow Problem

CS311H. Prof: Peter Stone. Department of Computer Science The University of Texas at Austin

Single machine parallel batch scheduling with unbounded capacity

Algorithm Design and Analysis

Data Structures and Algorithms Written Examination

Introduction to Logic in Computer Science: Autumn 2006

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

Handout #Ch7 San Skulrattanakulchai Gustavus Adolphus College Dec 6, Chapter 7: Digraphs

Approximation Algorithms

Analysis of Algorithms, I

Vieta s Formulas and the Identity Theorem

Scheduling Shop Scheduling. Tim Nieberg

Discrete Mathematics Problems

NP-Completeness I. Lecture Overview Introduction: Reduction and Expressiveness

One last point: we started off this book by introducing another famously hard search problem:

Discrete Mathematics & Mathematical Reasoning Chapter 10: Graphs

Euler Paths and Euler Circuits

2. (a) Explain the strassen s matrix multiplication. (b) Write deletion algorithm, of Binary search tree. [8+8]

Max Flow, Min Cut, and Matchings (Solution)

P versus NP, and More

Discuss the size of the instance for the minimum spanning tree problem.

Linear Programming Problems

Why Study NP- hardness. NP Hardness/Completeness Overview. P and NP. Scaling 9/3/13. Ron Parr CPS 570. NP hardness is not an AI topic

Near Optimal Solutions

Boulder Dash is NP hard

! X is a set of strings. ! Instance: string s. ! Algorithm A solves problem X: A(s) = yes iff s! X.

Cpt S 223. School of EECS, WSU

CAD Algorithms. P and NP

School Timetabling in Theory and Practice

136 CHAPTER 4. INDUCTION, GRAPHS AND TREES

Network File Storage with Graceful Performance Degradation

JUST-IN-TIME SCHEDULING WITH PERIODIC TIME SLOTS. Received December May 12, 2003; revised February 5, 2004

On the Relationship between Classes P and NP

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

Solutions to Homework 6

8.1 Min Degree Spanning Tree

Guessing Game: NP-Complete?

Simple Graphs Degrees, Isomorphism, Paths

Chapter 6: Graph Theory

THE PROBLEM WORMS (1) WORMS (2) THE PROBLEM OF WORM PROPAGATION/PREVENTION THE MINIMUM VERTEX COVER PROBLEM

Exponential time algorithms for graph coloring

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. #-approximation algorithm.

CSE 326, Data Structures. Sample Final Exam. Problem Max Points Score 1 14 (2x7) 2 18 (3x6) Total 92.

Part 2: Community Detection

Chapter Load Balancing. Approximation Algorithms. Load Balancing. Load Balancing on 2 Machines. Load Balancing: Greedy Scheduling

Bicolored Shortest Paths in Graphs with Applications to Network Overlay Design

The Goldberg Rao Algorithm for the Maximum Flow Problem

NP-Completeness and Cook s Theorem

6.3 Conditional Probability and Independence

Applied Algorithm Design Lecture 5

Math 319 Problem Set #3 Solution 21 February 2002

Introduction to computer science

OHJ-2306 Introduction to Theoretical Computer Science, Fall

Math Circle Beginners Group October 18, 2015

Triangle deletion. Ernie Croot. February 3, 2010

1(a). How many ways are there to rearrange the letters in the word COMPUTER?

Graphical degree sequences and realizations

This puzzle is based on the following anecdote concerning a Hungarian sociologist and his observations of circles of friends among children.

Linear Programming. March 14, 2014

1. Nondeterministically guess a solution (called a certificate) 2. Check whether the solution solves the problem (called verification)

CoNP and Function Problems

International Journal of Advanced Research in Computer Science and Software Engineering

Homework until Test #2

NP-completeness and the real world. NP completeness. NP-completeness and the real world (2) NP-completeness and the real world

Mathematical Induction. Lecture 10-11

Answer Key for California State Standards: Algebra I

COMBINATORIAL PROPERTIES OF THE HIGMAN-SIMS GRAPH. 1. Introduction

1. Write the number of the left-hand item next to the item on the right that corresponds to it.

Reading 13 : Finite State Automata and Regular Expressions

Multiplication and Division with Rational Numbers

(Refer Slide Time: 01.26)

! Solve problem to optimality. ! Solve problem in poly-time. ! Solve arbitrary instances of the problem. !-approximation algorithm.

Answer: (a) Since we cannot repeat men on the committee, and the order we select them in does not matter, ( )

Social Media Mining. Graph Essentials

each college c i C has a capacity q i - the maximum number of students it will admit

V. Adamchik 1. Graph Theory. Victor Adamchik. Fall of 2005

Mathematical Induction

6.852: Distributed Algorithms Fall, Class 2


Lecture 17 : Equivalence and Order Relations DRAFT

Graph Theory Origin and Seven Bridges of Königsberg -Rhishikesh

Social Media Mining. Network Measures

Transcription:

Homework 3: This homework is due by 4pm, November 10, 2015. They will be accepted without penalty until noon, November 11, 2015, after which no credit will be given. Your homework must be turned in as a PDF file and uploaded to the class blackboard page. As a reminder, while you may discuss problems with classmates, you are not allowed to leave such a conversation with any written (typed, etched, photographed, etc.) record of the conversation. 1. A Hamiltonian cycle of a graph G is a simple cycle that visits every vertex exactly once. Suppose someone gives you a function HamCycle(G), which, given an undirected graph G, returns true if G has a Hamiltonian cycle and false if G does not. Use this function to create an algorithm that outputs the sequence of vertices that defines a Hamiltonian cycle, or correctly states that G does not have a Hamiltonian cycle. Your algorithm must make no more than O(E) calls to the HamCycle function, where E is the number of edges in G. If you describe your algorithm using pseudo-code, please also give a short english description of the main idea. Prove that your algorithm gives a valid Hamiltonian Cycle, including on graphs that contain multiple Hamiltonian Cycles. Solution 1: Description: Run HamCycle(G) and if false then G does not have a HamCycle. If G does have a Hamiltonian Cycle then we do the following to find an example cycle. For some vertex v V and for an edge e = (v, u) E: remove e from original graph, G = G e. Run HamCycle(G ). Remove all edges e on v until you return false. If false then the most recent edge is necessary to the Hamiltonian Cycle. Put this e back into G. Put v into a list, H, of vertices that form the Hamiltonian cycle. Set the endpoint u of the most recent necessary edge equal to v, v = u. Test all edges until you return to the first explored vertex or until all edges in G have been checked. Algorithm: Here is some psuedo-code for a potential algorithm. function HCVertices(G) H = [] Choose a starting edge e = (v, u) next while G has unchecked edges do if HamCycle(G) then for all edges on v do e (v, u) G G e if HamCycle(G ) then G = G else add v to H mark e as checked next u v next return H There isn t a Ham Cycle anymore keep e The next vertex in the cycle connected to v 1

Solution 1: (cont) Proof of Correctness: (a) We know that this algorithm will terminate. It will return an empty set of vertices if G does not have a Hamiltonian Cycle. Otherwise it will return the vertices in order of a valid Hamiltonian Cycle. (b) We know the algorithm will return the vertices in the correct order. After each necessary edge e is found the next edges checked are connected to e. There must be a connecting edge among those searched because a Hamiltonion cycle is by definition a closed loop. Once all edges are checked, we return H, which is a list of connected vertices that results in a cycle that visits every vertex once. All unnecessary edges will not contribute to the order of vertices returned because unnecessary edges to the current Ham Cycle will be ignored, even if they are part of another Ham Cycle. They will be removed and HamCycle will return true because the edges for the returned Ham Cycle will be present. 2. Fair 3-coloring: Given a graph G = (V, E), where V is a multiple of 3, the Fair 3-coloring problem asks if G can be 3-colored so that there are the same number of nodes of each color ( V /3 ). Prove that Fair 3-coloring is NP-complete. You can prove this with a reduction from any NP-complete problem, including the standard 3-coloring problem. Review: Proving Similar Hardness : if you can show that one problem reduces to another problem (with some time constraint) and vice versa (with the same time constraint) then those two problems are equally hard to solve. Review: Proving NP-Completeness Definition of NP-Complete: A problem U NP Complete if: U NP For all H NP, H p U Proving NP-Completeness: Based on Cook s Theorem we know that any problem in NP can be solved by SAT and that SAT is in NP. From there we have developed a longer list of NP-Complete problems. That s why we don t have to prove both directions of the reduction. In order to prove that a new problem, U, is NP-Complete we first show that it is in NP. If in NP we know that it reduces to any know NP-Complete problem. Then we show a reduction from H (some known NP-Complete Problem) to U. Because we know H is NP-Complete it is reducible from any problem P NP thus P NP P p H p U. 2

Prove U NP: We suspect this problem is hard and can t be solved in polynomial time. To show that it is at least in NP we need to show that we can verify some input to the problem in polynomial time. Thus we design an algorithm which can verify in polynomial time whether an instance is a solution to the problem or not. Prove for all H NP, H p U H p U: Reduce from known hard problem H to unknown problem U. If H reduces to U, it means we can use U to solve H. When we prove this reduction we show that H cannot be harder than U because a solution to U provides a solution to H. Thus we prove U is just as hard as H, which we know is NP-Hard. This process is outlined below: (a) Assume for contradiction that the problem, U (the one you re trying to prove is NP-Hard), is actually solvable in polynomial time. (b) Show that some known NP-Complete problem, H, can be solved in polynomial time using U as a subroutine. (c) Get a contradiction to your original assumption that U is solvable in polynomial time because we know that H is not solvable in polynomial time. (d) Thus U is also NP-Hard In Practice The steps we have done in class are acceptable shorthand for the above formal proof structure. Those steps are: (a) Prove U NP: Let C be a certificate that describes an answer to an arbitrary instance problem U. Argue that you can verify in polynomial time whether or not C is a valid answer to that instance. (b) Prove U is NP-HARD: Pick some problem H that is known to be NP-Complete. Show how to reduce an instance of problem H to be an instance of problem U. Prove (a) your reduction runs in polynomial time, and (b) the answer for any input to the original problem H is the same as the answer when you ask U about the transformed input. 3

Solution 2: Reduction: 3-Color p Fair3-Color (reduce from known NP-Complete to unknown) (a) Assume, for contradiction, that fair3-color is solvable in polynomial time. i. Assumptions are like magic boxes. ii. Basically we now can say in polynomial time if any graph with V mod 3 = 0, is Fair3-colorable or not. (b) Show that 3-Color can be solved in polynomial time using fair3-color as a subroutine given any graph G. i. Any given graph might have V mod 3 > 0, in that case it wouldn t be solvable by fair3-color but still could be 3-Colorable. Thus we have to transform G in polynomial time such that we can use fair3-color on the new graph G to prove the original graph G is 3-Colorable. It is important this transformation is in polynomial time because we re trying to show that a polynomial solution exists for 3-Color when we assume one exists for fair3- Color. Transformation: Given a graph G transform it in polynomial time such that fair3-color(g ) proves 3-Color(G) For each vertex v in G add 2 new vertices to and connect them to each other and to v. Proof of Correctness: fair3-color(g ) 3-Color(G) G G thus by definition it must be 3-Colorable if it is Fair 3- Colorable 3-Color(G) fair3-color(g ) If G is 3-Colorable then for each vertex v in G is able to be colored with one color while the 2 vertices added in G represent the 2 other colors. Thus every node in G has a corresponding triplet of nodes in G. Each of these 3 nodes have a different color, so G has n-nodes of each color. 3. A circular communication network consists of n nodes on a cycle, numbered 0 through n 1 clockwise around the cycle. This problem considers routing a collection of calls through a circular connection. A set C of calls is given; each call is a pair (i, j) originating at node i and destined to node j. That call has a cost c(i, j) which is the load of that call (e.g. how much data that call requires). The call can be routed either clockwise or counterclockwise around the cycle. The objective is to route the calls so as to minimize the maximum load on any link in the network. We define the load L i on link i to be the cost of all the calls routed through edge (i, i + 1) (wrapping around to 0 if i+1=n). (a) Give a 2-approximation algorithm for this problem. If it helps, you may assume that all call costs c(i,j) are 1 (but note that it is not necessary that there is a call between every pair of nodes i,j). (b) Required for 541 students, bonus for 441 students. Show that this problem is NPcomplete (Hint: you may, but are not required, to try to reduce from Partition). I believe 4

this is easier if you include the call costs as part of the problem. Solution 3a: Description: Algorithm: Route the calls greedily by shortest path. Here is some psuedo-code for a potential algorithm. function CircRouting(G, C) G V = n, E = connect all v in circle while C is not empty do Remove some c(i, j) from C Route c through ShortestPath((i, j)) return highest cost edge e Proof of Correctness: The algorithm will return a routing of all calls. The cost of that routing is defined by the edge which has the highest cost routed through it. Let us name this edge L and also use L to define the cost of the calls routed through it. We now prove that L 2H*, where H* is the cost of the max load edge in the optimal routing. Define M to be the edge exactly opposite L. In our approximation, we know that all calls through L will not go through some edge M. Our algorithm routes based on the shortest path from some i to some j. The path that includes L and M is longer than half the circle. Our algorithm wouldn t have routed the call that way because there exists a shorter path. This is true for both and even and odd number of vertices. In the case of an odd number you can pick either edge across from L as M. The optimal solution may route some calls over these special edges L, M. Let s define the cost of calls that OPT routes on these edges L*, M*. All the calls we routed through L in the approximation, go from one side of L to the other side of L (otherwise, the shortest path wouldn t cross L). Therefore, OPT must route those calls from one side to the other. Perhaps OPT routes some of those call through M, but all the calls must be routed through either L or M. Therefore L* + M* L. (this is because OPT may route other calls through these edges as well). Thus L* or M* has to be at least equal to half of L. Meaning some edge in the optimal solution is at least as big at L 2. If some edge in the OPT solution has cost at least L 2, then the max edge has cost L 2, so the cost of the optimal solution H* L 2. We can rewrite this as L 2H and we have proven our 2-Approximation. 5

Solution 3b: (reduce from known NP-Complete to un- Reduction: Partition p CircRouting known) Transformation: Given a list of n integers N, where S is the sum over all the integers, transform the input in polynomial time such that CircRouting(N ) proves Partition(N) Create a circular routing with 4 nodes, s, a, t, b, in order around the circle. So there are 2 paths from (s, t). There are n calls C between s and t. For each call, it has a cost c(s, t) that corresponds to the value of each integer in N. If you can achieve a maximum edge load of S 2 in the circular routing of these calls then you can prove there is a partition Partition(N) Proof of Correctness: The algorithm will return highest cost edge L such that L 2H*, the cost of the max load edge in the optimal routing. CircRouting(N ) Partition(N) If a max load of S 2 is possible for CircRouting(N ) with call costs corresponding to the n numbers in Partition(N) then the load of the second path in CircRouting(N ) must also be S 2. The calls can be split to create a max load of S 2, thus the integers can be partitioned into 2 sets with sum equal to S 2. Partition(N) CircRouting(N ) If you can partition the integers in N into 2 sets with sum = S 2. Then the calls of the circular routing problem can be split between the two paths of the problem in the same way giving a max load of S 2. 6