cs4102 algorithms
play

CS4102 Algorithms Fall 2018 Warm up: Grab cookies! Start with 2, - PowerPoint PPT Presentation

CS4102 Algorithms Fall 2018 Warm up: Grab cookies! Start with 2, leftovers will be at regrade office hours Vegan & Gluten-free are available Courtesy of Nate and Robbie Todays Keywords Reductions Bipartite Matching Vertex


  1. CS4102 Algorithms Fall 2018 Warm up: Grab cookies! Start with 2, leftovers will be at regrade office hours Vegan & Gluten-free are available Courtesy of Nate and Robbie

  2. Today’s Keywords • Reductions • Bipartite Matching • Vertex Cover • Independent Set • NP-Completeness 2

  3. CLRS Readings • Chapter 34 3

  4. Homeworks • HW9 due Friday 12/7 at 11pm – Written (use LaTeX) – Graphs 4

  5. 𝑙 Independent Set Is there a set of non-adjacent nodes of size 𝑙 ? 5

  6. 𝑙 Vertex Cover Is there a set of nodes of size 𝑙 which covers every edge? 6

  7. Reduction Idea 𝑇 is an independent set of 𝐻 iff 𝑊 − 𝑇 is a vertex cover of 𝐻 Independent Set Vertex Cover 7

  8. Reduction Idea 𝑇 is an independent set of 𝐻 iff 𝑊 − 𝑇 is a vertex cover of 𝐻 Vertex Cover Independent Set 8

  9. MacGyver’s Reduction Problem we do know how to solve Problem we don’t know how to solve Opening a door Lighting a fire Aim duct at door, 𝐶 𝐵 insert keg How? Solution for 𝑩 Solution for 𝑪 Keg cannon Alcohol, wood, battering ram matches Put fire under the Keg Reduction 9

  10. MaxVertCov 𝑊 -Time Reducable to MinIndSet MinVertCov O(V) Time MaxIndSet Do nothing 𝐶 𝐵 Using any Algorithm for MinVertCov Take complement of solution Solution for MinVertCov Solution for MaxIndSet 𝑍 𝑌 Reduction 10

  11. Corollary MinVertCov O(V) Time MaxIndSet Do nothing 𝐶 𝐵 If Solving 𝑩 was Using any Algorithm for MinIndSet always slow Then this shows solving 𝑪 is also slow Take complement of solution Solution for MinVertCov Solution for MaxIndSet 𝑍 𝑌 Reduction 11

  12. MaxIndSet 𝑊 -Time Reducable to MinVertCov MaxIndSet MinVertCov O(V) Time Do nothing 𝐶 𝐵 Using any Algorithm for MaxIndSet Solution for MinVertCov Solution for MaxIndSet Take complement of solution 𝑍 𝑌 Reduction 12

  13. Corollary MaxIndSet MinVertCov O(V) Time Do nothing 𝐶 𝐵 If Solving 𝑩 was Using any Algorithm for MaxVertCov always slow Then this shows solving 𝑪 is also slow Solution for MinVertCov Solution for MaxIndSet Take complement of solution 𝑍 𝑌 Reduction 13

  14. Conclusion • MaxIndSet and MinVertCov are either both fast, or both slow – Spoiler alert: We don’t know which! • (But we think they’re both slow) – Both problems are NP-Complete 14

  15. Problem Types • Decision Problems: If we can solve this – Is there a solution? • Output is True/False – Is there a vertex cover of size 𝑙 ? • Search Problems: Then we can solve this – Find a solution • Output is complex – Give a vertex cover of size 𝑙 • Verification Problems: – Given a potential solution, is it valid? • Output is True/False – Is this a vertex cover of size 𝑙 ? 15

  16. P vs NP • P – Deterministic Polynomial Time – Problems solvable in polynomial time • 𝑃(𝑜 𝑞 ) for some number 𝑞 • NP NP – Non-Deterministic Polynomial Time P – Problems verifiable in polynomial time • 𝑃(𝑜 𝑞 ) for some number 𝑞 • Open Problem: Does P=NP? – Certainly 𝑄 ⊆ 𝑂𝑄 16

  17. 𝑙 -Independent Set is NP • To show: Given a potential solution, can we verify it in 𝑃(𝑜 𝑞 ) ? [𝑜 = 𝑊 + 𝐹] How can we verify it? 1. Check that it’s of size 𝑙 𝑃(𝑊) 2. Check that it’s an independent set 𝑃(𝑊 2 ) 17

  18. 𝑙 -Vertex Cover is NP • To show: Given a potential solution, can we verify it in 𝑃(𝑜 𝑞 ) ? [𝑜 = 𝑊 + 𝐹] How can we verify it? 1. Check that it’s of size 𝑙 𝑃(𝑊) 2. Check that it’s a Vertex Cover 𝑃(𝐹) 18

  19. NP-Hard • How can we try to figure out if P=NP? NP-H • Identify problems at least as “hard” as NP At least as “hard” as NP – If any of these “hard” problems can be solved in polynomial time, then all NP problems can be solved in polynomial time. NP • Definition: NP-Hard: – 𝐶 is NP-Hard if ∀𝐵 ∈ 𝑂𝑄, 𝐵 ≤ 𝑞 𝐶 P – 𝐵 ≤ 𝑞 𝐶 means 𝐵 reduces to 𝐶 in polynomial time 19

  20. NP-Hardness Reduction 𝑃(𝑜 𝑞 ) Problem to show is NP-Hard Any NP-Hard Problem 𝐶 𝐵 If This could be done in Polynomial time Then this could be done in polynomial time Solution for 𝑩 Solution for 𝑪 𝑍 𝑌 Reduction 20

  21. NP-Complete • “Together they stand, together they fall” NP-H • Problems solvable in polynomial time iff ALL NP problems are • NP-Complete = NP ∩ NP-Hard NP-C • How to show a problem is NP-Complete? NP – Show it belongs to NP P • Give a polynomial time verifier – Show it is NP-Hard • Give a reduction from another NP-H problem We now just need a FIRST NP-Hard problem 21

  22. NP-Completeness 𝑃(𝑜 𝑞 ) Any other NP-Complete Problem Any NP-Complete Problem 𝐶 𝐵 If This could be done in Polynomial time Then this could be done in polynomial time Solution for 𝑩 Solution for 𝑪 𝑍 𝑌 Reduction 22

  23. NP-Completeness 𝑃(𝑜 𝑞 ) Any other NP-Complete Problem Any NP-Complete Problem 𝐶 𝐵 If this cannot be done in polynomial time Then this cannot be done in polynomial time Solution for 𝑩 Solution for 𝑪 𝑍 𝑌 Reduction 23

  24. 3-SAT • Shown to be NP-Hard by Cook and Levin (independently) • Given a 3-CNF formula (logical AND of clauses, each an OR of 3 variables), Is there an assignment of true/false to each variable to make the formula true? 𝑦 ∨ 𝑧 ∨ 𝑨 ∧ 𝑦 ∨ 𝑧 ∨ 𝑧 ∧ 𝑣 ∨ 𝑧 ∨ 𝑨 ∧ 𝑨 ∨ 𝑦 ∨ 𝑣 ∧ (𝑦 ∨ 𝑧 ∨ 𝑨 ) 𝒚 = 𝒖𝒔𝒗𝒇 Clause 𝒛 = 𝒈𝒃𝒎𝒕𝒇 Variables 𝒜 = 𝒈𝒃𝒎𝒕𝒇 𝒗 = 𝒖𝒔𝒗𝒇 24

  25. 𝑙 -Independent Set is NP-Complete 1. Show that it belongs to NP – Give a polynomial time verifier (slide 21) 2. Show it is NP-Hard – Give a reduction from a known NP-Hard problem Show 3𝑇𝐵𝑈 ≤ 𝑞 𝑙𝐽𝑜𝑒𝑇𝑓𝑢 – 25

  26. 3𝑇𝐵𝑈 ≤ 𝑞 𝑙𝐽𝑜𝑒𝑇𝑓𝑢 𝑃(𝑜 𝑞 ) 𝑙 -Ind Set 3SAT 𝐶 𝐵 Solution for 3SAT Solution for 𝑙 -Ind Set 𝑍 𝑌 Reduction 26

  27. Instance of 3SAT to Instance of 𝑙 IndSet 𝑦 ∨ 𝑧 ∨ 𝑨 ∧ 𝑦 ∨ 𝑧 ∨ 𝑧 ∧ 𝑣 ∨ 𝑧 ∨ 𝑨 ∧ 𝑨 ∨ 𝑦 ∨ 𝑣 ∧ (𝑦 ∨ 𝑧 ∨ 𝑨 ) 𝑨 𝑦 𝑣 𝑣 𝑦 𝑣 𝑦 𝑧 𝑧 𝑨 𝑨 𝑧 𝑧 𝑨 𝑧 For each clause, produce a triangle graph with its three variables as nodes Connect each node to all of its opposites Let 𝑙 = number of clauses There is a 𝑙 -IndSet in this graph, iff there is a satisfying assignment 27

  28. 𝑙 IndSet ⇒ Satisfying Assignment 𝑦 ∨ 𝑧 ∨ 𝑨 ∧ 𝑦 ∨ 𝑧 ∨ 𝑧 ∧ 𝑣 ∨ 𝑧 ∨ 𝑨 ∧ 𝑨 ∨ 𝑦 ∨ 𝑣 ∧ (𝑦 ∨ 𝑧 ∨ 𝑨 ) 𝑨 𝑦 𝑣 𝑣 𝑦 𝑣 𝑦 𝑧 𝑧 𝑨 𝑧 𝑨 𝑧 𝑨 𝑧 𝒚 = 𝒖𝒔𝒗𝒇 𝒛 = 𝒈𝒃𝒎𝒕𝒇 𝒜 = 𝒈𝒃𝒎𝒕𝒇 One node per triangle is in the Independent set: 𝒗 = 𝒖𝒔𝒗𝒇 because we can have exactly 𝑙 total in the set, and 2 in a triangle would be adjacent If 𝑦 is selected in some triangle, 𝑦 is not selected in any triangle: Because every 𝑦 is adjacent to every 𝑦 Set the variable which each included node represents to “true” 28

  29. Satisfying Assignment ⇒ 𝑙 IndSet 𝑦 ∨ 𝑧 ∨ 𝑨 ∧ 𝑦 ∨ 𝑧 ∨ 𝑧 ∧ 𝑣 ∨ 𝑧 ∨ 𝑨 ∧ 𝑨 ∨ 𝑦 ∨ 𝑣 ∧ (𝑦 ∨ 𝑧 ∨ 𝑨 ) 𝑨 𝑦 𝑣 𝑣 𝑦 𝑣 𝑦 𝑧 𝑧 𝑨 𝑧 𝑨 𝑧 𝑨 𝑧 𝒚 = 𝒖𝒔𝒗𝒇 𝒛 = 𝒈𝒃𝒎𝒕𝒇 𝒜 = 𝒈𝒃𝒎𝒕𝒇 Use one true variable from the assignment for each triangle 𝒗 = 𝒖𝒔𝒗𝒇 The independent set has 𝑙 nodes, because there are 𝑙 clauses If any variable 𝑦 is true then 𝑦 cannot be true 29

  30. 3𝑇𝐵𝑈 ≤ 𝑞 𝑙𝐽𝑜𝑒𝑇𝑓𝑢 𝑃(𝑜 𝑞 ) 𝑙 -Ind Set 3SAT 𝐶 Make triangles, connect 𝐵 opposites, 𝑙 = num clauses If This could be done in Polynomial time Then This could be done in polynomial time Solution for 3SAT Solution for 𝑙 -Ind Set Assign true to variables from selected nodes 𝑍 𝑌 Reduction 30

  31. 𝑙 -Vertex Cover is NP-Complete 1. Show that it belongs to NP – Give a polynomial time verifier (slide 22) 2. Show it is NP-Hard – Give a reduction from a known NP-Hard problem We showed 𝑙𝐽𝑜𝑒𝑇𝑓𝑢 ≤ 𝑞 𝑙𝑊𝑓𝑠𝑢𝐷𝑝𝑤 – • (Last Class) 31

  32. 𝑙𝐽𝑜𝑒𝑇𝑓𝑢 ≤ 𝑞 𝑙𝑊𝑓𝑠𝑢𝐷𝑝𝑤 𝑃(𝑜 𝑞 ) 𝑙𝐽𝑜𝑒𝑇𝑓𝑢 𝑙𝑊𝑓𝑠𝑢𝐷𝑝𝑤 𝐶 𝐵 𝑙 = 𝑊 − 𝑙 If This could be done in Polynomial time Then This could be done in polynomial time Solution for 𝑙𝐽𝑜𝑒𝑇𝑓𝑢 Solution for 𝑙𝑊𝑓𝑠𝑢𝐷𝑝𝑤 Take Complement of nodes 𝑍 𝑌 Reduction 32

  33. 𝑙 -Clique Problem • Clique: A complete subgraph 4-Clique • 𝑙 -Clique Problem: – Given a graph 𝐻 and a number 𝑙 , is there a clique of size 𝑙 ? 3-Clique 33

  34. 𝑙 -Clique is NP-Complete 1. Show that it belongs to NP – Give a polynomial time verifier 2. Show it is NP-Hard – Give a reduction from a known NP-Hard problem We will show 3𝑇𝐵𝑈 ≤ 𝑞 𝑙𝐷𝑚𝑗𝑟𝑣𝑓 – 34

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend