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



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

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

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

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

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

CMPSCI611: Approximating MAX-CUT Lecture 20

Lecture 7: NP-Complete Problems

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

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

CSC 373: Algorithm Design and Analysis Lecture 16

CAD Algorithms. P and NP

Problem Set 7 Solutions

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

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

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

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

Euler Paths and Euler Circuits

Introduction to Algorithms. Part 3: P, NP Hard Problems

Introduction to Logic in Computer Science: Autumn 2006

Lecture 19: Introduction to NP-Completeness Steven Skiena. Department of Computer Science State University of New York Stony Brook, NY

A Working Knowledge of Computational Complexity for an Optimizer

8.1 Min Degree Spanning Tree

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

Introduction to computer science

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

Algorithm Design and Analysis

Near Optimal Solutions

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

Guessing Game: NP-Complete?

Graph Theory Problems and Solutions

Applied Algorithm Design Lecture 5

Complexity Classes P and NP

Max Flow, Min Cut, and Matchings (Solution)

Notes on NP Completeness

The Classes P and NP. mohamed@elwakil.net

Approximation Algorithms

Satisfiability Checking

Analysis of Algorithms, I

5.1 Bipartite Matching

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

Scheduling Home Health Care with Separating Benders Cuts in Decision Diagrams

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

MATHEMATICAL ENGINEERING TECHNICAL REPORTS. An Improved Approximation Algorithm for the Traveling Tournament Problem

Social Media Mining. Graph Essentials

Simple Graphs Degrees, Isomorphism, Paths

6.852: Distributed Algorithms Fall, Class 2

SIMS 255 Foundations of Software Design. Complexity and NP-completeness

136 CHAPTER 4. INDUCTION, GRAPHS AND TREES

Exponential time algorithms for graph coloring

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

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

Tetris is Hard: An Introduction to P vs NP

Distributed Computing over Communication Networks: Maximal Independent Set

Chapter 6: Graph Theory

Generalized Induced Factor Problems

Data Structures and Algorithms Written Examination

Quantum Monte Carlo and the negative sign problem

OHJ-2306 Introduction to Theoretical Computer Science, Fall

Welcome to... Problem Analysis and Complexity Theory , 3 VU

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

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

The Classes P and NP

P versus NP, and More

Discrete Mathematics & Mathematical Reasoning Chapter 10: Graphs

Theoretical Computer Science (Bridging Course) Complexity

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

How To Solve A K Path In Time (K)

Tutorial 8. NP-Complete Problems

Lecture 16 : Relations and Functions DRAFT

On the Unique Games Conjecture

Lecture 1: Course overview, circuits, and formulas

Lecture 17 : Equivalence and Order Relations DRAFT

Computational complexity theory

Network Flow I. Lecture Overview The Network Flow Problem

COLLEGE ALGEBRA. Paul Dawkins

Class One: Degree Sequences

Decision Mathematics D1 Advanced/Advanced Subsidiary. Tuesday 5 June 2007 Afternoon Time: 1 hour 30 minutes

Quantum and Non-deterministic computers facing NP-completeness

Dynamic programming. Doctoral course Optimization on graphs - Lecture 4.1. Giovanni Righini. January 17 th, 2013

Solutions to Homework 6

Chapter. NP-Completeness. Contents

Mathematics for Algorithm and System Analysis

Fundamentals of algorithms

The Basics of Graphical Models

On the Relationship between Classes P and NP

Cost Model: Work, Span and Parallelism. 1 The RAM model for sequential computation:

High Performance Computing for Operation Research

WOLLONGONG COLLEGE AUSTRALIA. Diploma in Information Technology

Load balancing. David Bindel. 12 Nov 2015

Cloud Computing is NP-Complete

Discrete Mathematics Problems

The number of marks is given in brackets [ ] at the end of each question or part question. The total number of marks for this paper is 72.

CHOOSING THE BEST HEURISTIC FOR A NP-PROBLEM

Extremal Wiener Index of Trees with All Degrees Odd

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

IE 680 Special Topics in Production Systems: Networks, Routing and Logistics*

1 Definitions. Supplementary Material for: Digraphs. Concept graphs

Project and Production Management Prof. Arun Kanda Department of Mechanical Engineering Indian Institute of Technology, Delhi

Graph Theory Lecture 3: Sum of Degrees Formulas, Planar Graphs, and Euler s Theorem Spring 2014 Morgan Schreffler Office: POT 902

Boulder Dash is NP hard

Transcription:

Outline NP-completeness Examples of Easy vs. Hard problems Euler circuit vs. Hamiltonian circuit Shortest Path vs. Longest Path 2-pairs sum vs. general Subset Sum Reducing one problem to another Clique to Vertex Cover Hamiltonian Circuit to TSP TSP to Longest Simple Path NP & NP-completeness When is a problem easy? We ve seen some easy graph problems: Graph search Shortest-path Minimum Spanning Tree Not easy for us to come up with, but easy for the computer, once we know algorithm. When is a problem hard? Almost everything we ve seen in class has had a near linear time algorithm But of course, computers can t solve every problem quickly. In fact, there are perfectly reasonable sounding problems that no computer could ever solve in any amount of time. Today We ll see 3 pairs of similar problems, one version easy, one version hard. The lesson is that seemingly mild changes in problem statement can have a dramatic effect on algorithm speed. Euler Circuits A cycle that passes through every edge exactly once. Give example graph (square with X through it.) 1

Hamiltonian Circuit A cycle that passes through every vertex exactly once. Give example graph Finding an Eulerian Circuit Very simple criteria: If every vertex has even degree, then there is an Eulerian circuit. Reason: If a node has even degree, then one edge used to get to a node, and one edge used to get out. Never get stuck. Finding a Hamiltonian Circuit Nothing to do but enumerate all paths and see if any are Hamiltonian. How many paths? Draw example from box graph. Can think of all paths as a tree. Branching factor approximated by average degree d. Then d N leaves (paths). Exponential. Recall exponential curves from first lecture. Shortest vs. Longest Path Finding the shortest path is easy--that is, we know an efficient algorithm. Namely DFS or BFS. How do we find the longest path? Longest Path Again, no choice but to enumerate all paths. Q: Why doesn t DFS work? A node is visited only once, therefore only one path through each node is considered. But as we saw, there could be exponentially many paths. DFS is exploring only one per node. Subset Sum We saw 4 number sum in homework: Given a list of N integers and target k, are there 4 numbers that sum to k? General Subset Sum: Given N integers and a target k, is there some subset of integers that sum to k? 2

Solving Subset Sum Only thing to do is try every possible combination. How many possible subset are there of N integers? 2 N. So again, exponential in input size. For 4 numbers there are N choose 4 possible subsets to try. Approx. N 4. Outline: Day 2 We ve seen that there are a bunch of problems that seem to be hard. Today we ll see how these problems relate to one another. Def: P 1 is reducible to P 2 if there is a conversion from an instance X of P 1 to an instance Y of P 2 such that P 1 is yes for X iff P 2 is yes for Y. Clique to Vertex Cover We can reduce Clique to Vertex Cover. Given an input (G, k) to Clique: Build graph G complement Let k = n k Vertex Cover is as hard as Clique. If G has a k Clique then G has a k cover: Let C be the clique of size k. Let the cover be V-C. Then clearly every edge outside C is covered, and in G there are no edges in C. Size is n-k If G has a k cover then G has a k Clique: Let D be a cover in G of size k. Then there are no edges in V-D, since otherwise they wouldn t be covered. Therefore, V-D is a clique in G. Size of clique is n-k. TSP Travelling Salesman Problem: Given complete weighted graph G, integer k. Is there a cycle that visits all vertices with cost <= k? One of the canonical problems. Note difference from Hamiltonian cycle: graph is complete, and we care about weight. 3

Hamiltonian Cycle to TSP We can reduce Hamiltonian Cycle to TSP. Given graph G=(V, E): Construct complete graph G on N vertices with edge weights: 1 if (u, v) in E, 2 otherwise. Let k = N. Do example with N=5. TSP is as hard as Hamiltonian cycle. Proof If G has a Hamiltonian Cycle then G has a tour of weight N. Obvious. If G has a tour of weight N, then G has a Hamiltonian Cycle. Obvious. Ham. Cycle to longest path Recall, Longest Path: Given directed graph G, start node s, and integer k. Is there a simple path from s of length >= k? We ll use Directed Hamiltonian Cycle. The reduction Given a directed graph G. Pick any node as start vertex s. Create a new node t. For every edge (u, s), add an edge (u, t). Let k = N. Draw example Longest Path is as hard as Ham. Cycle Proof If G has a Ham. Cycle, then G has a path of length k from s. Follow the cycle starting at s, at the last step go to t instead of s. If G has a path of length k from s, then G has a Ham. Cycle. Path must have hit every node exactly once, and last step in path could have formed cycle in G. NP-completeness We ve seen that there are seemingly hard problems. That s kind of interesting. The really interesting part: A large class of these are equivalent. Solving one would give a solution for all of them! 4

What s NP-complete The pairs I picked weren t important. There is a large class of problems, called NPcomplete, such that any one can be reduced to any other. So given an algorithm for any NP-complete problem, all the others can be solved. Conversely, if we can prove there is no efficient algorithm for one, then there are no efficient algorithms for any. Satisfiability of logic formulas All sorts of constraint problems All sorts of graph problems Not an overstatement to say that every area of computer science comes up against NP-complete problems. What do we do about it? Approximation Algorithm: Can we get an efficient algorithm that guarantees something close to optimal? Heuristics: Can we get something that seems to work well most of the time? Restrictions: Longest Path is easy on trees, for example. Many hard problems are easy for restricted inputs. 5