Algorithms, Lecture 3 on NP : Nondeterminis7c Polynomial Time

Similar documents
NP and Computational Intractability

8.5 Sequencing Problems

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

Polynomial-Time Reductions

Computational Intractability 2010/4/15. Lecture 2

Classes of Problems. CS 461, Lecture 23. NP-Hard. Today s Outline. We can characterize many problems into three classes:

CSCI 1010 Models of Computa3on. Lecture 11 Proving Languages NP-Complete

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

NP-Complete Problems. More reductions

SAT, Coloring, Hamiltonian Cycle, TSP

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

NP and Computational Intractability

NP-Complete Reductions 2

Design and Analysis of Algorithms

Chapter 8. NP and Computational Intractability

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

CS 583: Algorithms. NP Completeness Ch 34. Intractability

Hamiltonian Cycle. Hamiltonian Cycle

NP Complete Problems. COMP 215 Lecture 20

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

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

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

8.5 Sequencing Problems. Chapter 8. NP and Computational Intractability. Hamiltonian Cycle. Hamiltonian Cycle

Lecture 4: NP and computational intractability

4/20/11. NP-complete problems. A variety of NP-complete problems. Hamiltonian Cycle. Hamiltonian Cycle. Directed Hamiltonian Cycle

VIII. NP-completeness

Algorithms Design & Analysis. Approximation Algorithm

Chapter 8. NP and Computational Intractability. Slides by Kevin Wayne. Copyright 2005 Pearson-Addison Wesley. All rights reserved.

Polynomial-time reductions. We have seen several reductions:

Algorithm Design and Analysis

Complexity, P and NP

Algorithm Design and Analysis

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

CSCI3390-Lecture 17: A sampler of NP-complete problems

Intractable Problems Part One

1. Introduction Recap

NP-complete Problems

More NP-Complete Problems

CS 580: Algorithm Design and Analysis

3/22/2018. CS 580: Algorithm Design and Analysis. Circuit Satisfiability. Recap. The "First" NP-Complete Problem. Example.

CMSC 441: Algorithms. NP Completeness

NP-Hardness reductions

Lecture 24 : Even more reductions

Topics in Complexity Theory

Chapter 34: NP-Completeness

CS Fall 2011 P and NP Carola Wenk

CSL 356: Analysis and Design of Algorithms. Ragesh Jaiswal CSE, IIT Delhi

Algorithms and Theory of Computation. Lecture 19: Class P and NP, Reduction

Automata Theory CS Complexity Theory I: Polynomial Time

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

Today: NP-Completeness (con t.)

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

Intro to Theory of Computation

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

NP-Complete Reductions 1

Today s Outline. CS 362, Lecture 23. Classes of Problems. NP-Hard. Review NP-Hardness and three more reductions. Jared Saia University of New Mexico

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

COP 4531 Complexity & Analysis of Data Structures & Algorithms

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

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

COMP 382. Unit 10: NP-Completeness

CS21 Decidability and Tractability

Lecture 15 - NP Completeness 1

4/30/14. Chapter Sequencing Problems. NP and Computational Intractability. Hamiltonian Cycle

NP Completeness and Approximation Algorithms

Polynomial-time Reductions

NP-Complete Reductions 3

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

1 Primals and Duals: Zero Sum Games

CS 161: Design and Analysis of Algorithms

Algorithm Design and Analysis

Today s Outline. CS 362, Lecture 24. The Reduction. Hamiltonian Cycle. Reduction Wrapup Approximation algorithms for NP-Hard Problems

Lecture 18: More NP-Complete Problems

BBM402-Lecture 11: The Class NP

Introduction. Pvs.NPExample

15-451/651: Design & Analysis of Algorithms October 31, 2013 Lecture #20 last changed: October 31, 2013

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

Correctness of Dijkstra s algorithm

July 18, Approximation Algorithms (Travelling Salesman Problem)

Data Structures in Java

NP-problems continued

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

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

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

NP-Completeness. NP-Completeness 1

NP-Complete problems

CS 580: Algorithm Design and Analysis

NP and NP-Completeness

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

Graph Theory and Optimization Computational Complexity (in brief)

Decision Problems TSP. Instance: A complete graph G with non-negative edge costs, and an integer

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

Lecture 13, Fall 04/05

Data Structures and Algorithms (CSCI 340)

The Complexity Classes P and NP. Andreas Klappenecker [partially based on slides by Professor Welch]

ECS122A Handout on NP-Completeness March 12, 2018

CSCI3390-Lecture 18: Why is the P =?NP Problem Such a Big Deal?

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

Hamiltonian Graphs Graphs

Chapter 3: Proving NP-completeness Results

Transcription:

Algorithms, Lecture 3 on NP : Nondeterminis7c Polynomial Time

Last week: Defined Polynomial Time Reduc7ons: Problem X is poly 7me reducible to Y X P Y if can solve X using poly computa7on and a poly number of calls to an algorithm solving Y. Up to poly factors, X is at least as easy as Y Up to poly factors, Y is harder than X

Last class: Defined NP: decision (yes/no) problems can check cer7ficates for yes answers in p7me Have poly 7me proof checkers: A poly 7me algorithm A so that if X(s) = yes, there exists a t so that A(s,t) = yes, and if X(s) = no, for all t, A(s,t) = no

Last class: Defined NP- Complete: 1. X NP, and 2. X is NP- hard X is NP- hard if: 1. for all Y NP, Y P X, or 2. CircuitSat P X, or 3. Y P X, for some NP- Hard Y, such as SAT, Independent Set, Vertex Cover

Last class: Proved CircuitSAT is NP- Hard. Proved CircuitSAT P SAT. In fact, proved CircuitSAT P 3- SAT Where 3- SAT is SAT, but each clause has at most 3 terms.

Last class: Proved CircuitSAT is NP- Hard. Proved CircuitSAT P SAT. In fact, proved CircuitSAT P 3- SAT Where 3- SAT is SAT, but each clause has at most 3 terms. Also possible to force each variable to appear at most 3 7mes

Also possible to force each variable to appear at most 3 7mes Say a variable x appears k 7mes. Create k new variables, x 1,, x k, one for each occurrence. Add clauses x 1 V x 2, x 2 V x 3,, x k- 1 V x k, x k V x 1 Only sa7sfied if all are equal.

Today Will prove more problems are NP- complete: 3- coloring Hamiltonian Cycle Travelling Salesman Problem

k- Coloring Given a graph G = (V,E), does there exist f : V {1,2,, k} (colors) So that for all (u,v) E f(u) f(v)? 3- colorable Not 3- colorable

k- Coloring Given a graph G = (V,E), does there exist f : V {1,2,, k} (colors) So that for all (u,v) E f(u) f(v)? 3- colorable Not 3- colorable

k- Coloring is NP- Complete Clearly in NP, because can check a proposed coloring To prove NP- hard, will show 3- SAT P 3- Coloring Given a collec7on of clauses C 1,, C k, each with at most 3 terms, on variables x 1,, x n produce graph G = (V,E) that is 3- colorable iff the clauses are sa7sfiable

3- Coloring is NP- Complete variable gadgets Create 3 special nodes: T, F, B (base), and one node for each term: x i and x i T F B x 1 x 1 x 2 x 2 x n x n In every 3- coloring, one of x i and x i is colored T and one is colored F

3- Coloring is NP- Complete variable gadgets Create 3 special nodes: T, F, B (base), and one node for each term: x i and x i T F B x 1 x 1 x 2 x 2 x n x n In every 3- coloring, one of x i and x i is colored T and one is colored F

3- Coloring is NP- Complete clause gadgets Consider clause x 1 V x 2 V x n B x 1 x 2 x n T F Claim: 3- colorable iff terms colored to sa7sfy clause

3- Coloring is NP- Complete clause gadgets Claim: 3- colorable iff terms colored to sa7sfy clause 1. If terms all colored F, then cannot 3- color B x 1 x 2 x n T F

3- Coloring is NP- Complete clause gadgets Claim: 3- colorable iff terms colored to sa7sfy clause 1. If terms all colored F, then cannot 3- color B x 1 x 2 x n T F

k- Coloring is NP- Complete clause gadgets Claim: 3- colorable iff terms colored to sa7sfy clause 1. If terms all colored F, then cannot 3- color B x 1 x 2 x n T F

3- Coloring is NP- Complete clause gadgets Claim: 3- colorable iff terms colored to sa7sfy clause 2. If some term true, can 3- color B x 1 x 2 x n T F

3- Coloring is NP- Complete clause gadgets Claim: 3- colorable iff terms colored to sa7sfy clause 2. If some term true, can 3- color B x 1 x 2 x n T F

3- Coloring is NP- Complete clause gadgets Claim: 3- colorable iff terms colored to sa7sfy clause 2. If some term true, can 3- color B x 1 x 2 x n T F

3- Coloring is NP- Complete T B F 3- colorable iff sa7sfiable x 1 x 1 x 2 x 2 x 3 x 3 x n x n x 1 V x 2 V x n

k- Coloring is NP- Complete T B F 3- colorable iff sa7sfiable x 1 x 1 x 2 x 2 x 3 x 3 x n x n x 1 V x 2 V x n x 2 V x 3 V x n

Hamiltonian Cycle: A cycle in a graph that hits each vertex once. Directed Hamiltonian Cycle: same, but in a directed graph

Directed Ham Cycle is NP- Complete Clearly in NP, because can check if a cycle is Hamiltonian To prove NP- hard, will show 3- SAT P Directed Ham Cycle Produce directed graph G = (V,E) that has Ham Cycle iff the clauses are sa7sfiable

Start: create graph with 2 n Ham Cycles, then create gadgets to restrict them 1: 2: 3: n:

Start: create graph with 2 n Ham Cycles, then create gadgets to restrict them 1: 2: 3: n:

Start: create graph with 2 n Ham Cycles, then create gadgets to restrict them 1: 2: 3: n: Must go top- to- bofom, and can traverse each row leg- to- right (True) or right- to- leg (False)

Start: create graph with 2 n Ham Cycles, then create gadgets to restrict them 1: 2: 3: n: Must go top- to- bofom, and can traverse each row leg- to- right (True) or right- to- leg (False)

Clause gadgets True False clause x 1 forces traverse first row 1: 2: 3: n:

Clause gadgets True False clause x 1 V x 2 V x n 1: 2: 3: n: Forces traverse 1, or 2, or n

Clause gadgets True False clause x 1 V x 2 V x n 2: To see must come back to same row, note that if do not is no hamiltonian path through unused down- link

Ham cycle iff sa7sfiable True False x 1 V x 2 V x n Pf. If sa7sfiable, traverse in order indicated by vars, picking up each clause once using some true term. 1: 2: 3: n:

Ham cycle iff sa7sfiable True False x 1 V x 2 V x n Pf. If Ham Cycle, must go top to bot 1: 2: 3: n: assign vars by direc7on if visit each clause node, then is made true by term on row from which make the visit.

Directed Ham Cycle P Ham Cycle 1. In directed problem, answer same if reverse all arrows. 2. To transform to undirected, replace each vertex v with three ver7ces: v in, v base, v out u v Replace directed (u,v) edge with (u out, v in ) u in u b u out v in v b v out

Directed Ham Cycle P Ham Cycle Replace directed (u,v) edge with (u out, v in ) u v u in u b u out v in v b v out w w in w b w out Directed Ham Cycle in original - > Ham Cycle Every Ham Cycle in the undirected graph must go in, base, out, in, base, out, in, base, out, etc, must correspond to a Ham Cyc in directed graph

Directed Ham Cycle P Ham Cycle Replace directed (u,v) edge with (u out, v in ) u v u in u b u out v in v b v out w w in w b w out Directed Ham Cycle in original - > Ham Cycle Every Ham Cycle in the undirected graph must go in, base, out, in, base, out, in, base, out, etc, must correspond to a Ham Cyc in directed graph

TSP (Travelling Salesperson Problem) Given n loca7ons, a distance func7on d(u,v) and a total distance D, does there exist a tour through all loca7ons of total distance at most L? hfp://www.tsp.gatech.edu/usa13509/usa13509_info.html

TSP (Travelling Salesperson Problem) Given n loca7ons, a distance func7on d(u,v) and a total distance D, does there exist a tour through all loca7ons of total distance at most L? hfp://www.tsp.gatech.edu/usa13509/usa13509_sol.html

RL5915 optimal solution An optimal solution for RL5915 is given by the following tour, which has length 565530. hfp://www.tsp.gatech.edu/rl5915/rl5915_sol.html

TSP is NP- complete Ham Cycle P TSP Given graph G = (V,E), create one loca7on for each vertex, d(u,v) = 1 if (u,v) E 2 otherwise Target distance = V A tour of all loca7ons that returns to start and has total length V must use exactly n edges of G

TSP is NP- complete Ham Cycle P TSP Given graph G = (V,E), create one loca7on for each vertex, d(u,v) = 1 if (u,v) E 2 otherwise This is an abstract distance func7on.

TSP is NP- complete Ham Cycle P TSP Given graph G = (V,E), create one loca7on for each vertex, d(u,v) = 1 if (u,v) E 2 otherwise This is an abstract distance func7on. Remains NP- hard for integer points in plane.

Issue with Planar TSP If input is loca7ons of points, instead of distances The problem is not known to be in NP, because do not know if can compare distances in polynomial 7me. For integers x 1,, x n integer t, do not have poly 7me algorithm to test if X p xi apple t i