Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 32.

Similar presentations


Presentation on theme: "CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 32."— Presentation transcript:

1 CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 32

2 Traveling Salesperson Problem TSP: Given a set of n cities and a pairwise distance function d(u, v), is there a tour of length  D? All 13,509 cities in US with a population of at least 500 Reference: http://www.tsp.gatech.edu

3 Traveling Salesperson Problem TSP: Given a set of n cities and a pairwise distance function d(u, v), is there a tour of length  D? Optimal TSP tour Reference: http://www.tsp.gatech.edu

4 Traveling Salesperson Problem 11,849 holes to drill in a programmed logic array Reference: http://www.tsp.gatech.edu

5 Traveling Salesperson Problem Optimal TSP tour Reference: http://www.tsp.gatech.edu

6 Traveling Salesperson Problem TSP: given a set of n cities and a pairwise distance function d(u, v), is there a tour of length  D? HAM-CYCLE: given a graph G = (V, E), does there exists a simple cycle that contains every node in V? Claim: HAM-CYCLE  P TSP Pf: –Given instance G = (V, E) of HAM-CYCLE, create n cities with distance function –TSP instance has tour of length  n iff G has Hamiltonian cycle

7 3-Dimensional Matching Example: Given n instructors, n courses, and n times, and a list of the possible courses and times each instructor is willing to teach, is it possible to make an assignment so that all courses are taught at different times? InstructorCourseTime WayneCOS 423MW 11-12:20 WayneCOS 423TTh 11-12:20 WayneCOS 226TTh 11-12:20 WayneCOS 126TTh 11-12:20 TardosCOS 523TTh 3-4:20 TardosCOS 423TTh 11-12:20 TardosCOS 423TTh 3-4:20 KleinbergCOS 226TTh 3-4:20 KleinbergCOS 226MW 11-12:20 KleinbergCOS 423MW 11-12:20

8 3-Dimensional Matching 3D-MATCHING: Given disjoint sets X, Y, and Z, each of size n and a set T  X  Y  Z of triples, does there exist a set of n triples in T such that each element of X  Y  Z is in exactly one of these triples? Claim: 3-SAT  P 3D-MATCHING Pf: Given an instance  of 3-SAT, we construct an instance of 3D-matching that has a perfect matching iff  is satisfiable

9 3-Dimensional Matching Construction (part 1) –Create gadget for each variable x i with 2k core and tip elements –No other triples will use core elements –In gadget i, 3D-matching must use either both grey triples or both blue ones x1x1 x3x3 x2x2 core k = 2 clauses n = 3 variables true false clause 1 tips number of clauses set x i = trueset x i = false

10 3-Dimensional Matching Construction (part 2) –Now we add elements to model the clauses and to constrain the assignments we can choose –In the language of 3D-matching, the clause tells us: “The matching on the cores of the gadgets should leave the grey tips of the first gadget free; or it should leave the blue tips of the second gadget free; or it should leave the grey tips of the third gadget free”

11 3-Dimensional Matching Construction (part 2) –For each clause C j create two core elements and three triples –Exactly one of these triples will be used in any 3D-matching –For sample clause j, ensures any 3D-matching uses either (i) grey core of x 1 or (ii) blue core of x 2 or (iii) grey core of x 3 x1x1 x3x3 x2x2 clause 1 tips core true false clause j gadget

12 3-Dimensional Matching Almost done with the construction, but there’s still one problem –Suppose the set of clauses has a satisfying assignment –Then we make corresponding choices of grey/blue for each variable gadget –But this leaves at least one free tip for each clause gadget

13 3-Dimensional Matching Construction (part 3) –For each tip, add a cleanup gadget x1x1 x3x3 x2x2 core cleanup gadget true false clause 1 gadget clause 1 tips

14 3-Dimensional Matching Suppose there is a perfect 3D-matching in the instance we have constructed –In each variable gadget x i the matching chooses either all the grey triples or all the blue triples grey  set x i = 1 in the 3-SAT instance blue  set x i = 0 in the 3-SAT instance –Consider clause C j ; has it been satisfied? Yes, the two core elements have been covered and thus at least one of the three variable gadgets corresponding to a term in C j made the “correct” grey/blue decision; this induces a variable assignment that satisfies C j But, have we constructed a 3D-matching? What are the X, Y, and Z sets?

15 3-Dimensional Matching Claim: Instance has a 3D-matching iff  is satisfiable Detail: What are X, Y, and Z? Does each triple contain one element from each of X, Y, Z? x1x1 x3x3 x2x2 core cleanup gadget true false clause 1 gadget clause 1 tips

16 3-Dimensional Matching Claim: Instance has a 3D-matching iff  is satisfiable Detail: What are X, Y, and Z? Does each triple contain one element from each of X, Y, Z? x1x1 x3x3 x2x2 core cleanup gadget clause 1 gadget clause 1 tips


Download ppt "CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 32."

Similar presentations


Ads by Google