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

Advertisement


Advertisement
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

/ Approximation Algorithms Lecturer: Michael Dinitz Topic: Steiner Tree and TSP Date: 01/29/15 Scribe: Katie Henry

Minimum Spanning Trees

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

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

2.3 Scheduling jobs on identical parallel machines

CMPSCI611: Approximating MAX-CUT Lecture 20

CSC 373: Algorithm Design and Analysis Lecture 16

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:

Informatique Fondamentale IMA S8

CAD Algorithms. P and NP

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

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

1 Basic Definitions and Concepts in Graph Theory

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

Euler Paths and Euler Circuits

Introduction to Algorithms Review information for Prelim 1 CS 4820, Spring 2010 Distributed Wednesday, February 24

Problem Set 7 Solutions

Introduction to Logic in Computer Science: Autumn 2006

CSE 20: Discrete Mathematics for Computer Science. Prof. Miles Jones. Today s Topics: Graphs. The Internet graph

Graph Theory. Euler tours and Chinese postmen. John Quinn. Week 5

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

A Working Knowledge of Computational Complexity for an Optimizer

Chapter 4: Trees. 2. Theorem: Let T be a graph with n vertices. Then the following statements are equivalent:

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

Planar Graph and Trees

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

8.1 Min Degree Spanning Tree

Answers to some of the exercises.

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

Algorithm Design and Analysis

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

Introduction to computer science

Guessing Game: NP-Complete?

Analysis of Algorithms, I

Near Optimal Solutions

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

Planar Graphs and Graph Coloring

Notes on NP Completeness

Applied Algorithm Design Lecture 5

Graph Theory Problems and Solutions

Combinatorics: The Fine Art of Counting

Max Flow, Min Cut, and Matchings (Solution)

An Exact Algorithm for Steiner Tree Problem on Graphs

Approximation Algorithms

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

Fall 2015 Midterm 1 24/09/15 Time Limit: 80 Minutes

Complexity Classes P and NP

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

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

136 CHAPTER 4. INDUCTION, GRAPHS AND TREES

Memoization/Dynamic Programming. The String reconstruction problem. CS125 Lecture 5 Fall 2016

6.852: Distributed Algorithms Fall, Class 2

CSL851: Algorithmic Graph Theory Semester I Lecture 1: July 24

The Classes P and NP.

5.1 Bipartite Matching

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

Trees and structural induction

GRAPH THEORY and APPLICATIONS. Trees

Lecture 7: Approximation via Randomized Rounding

Finding the Shortest Move-Sequence in the Graph-Generalized 15-Puzzle is NP-Hard

Satisfiability Checking

Exponential time algorithms for graph coloring

Simple Graphs Degrees, Isomorphism, Paths

6.042/18.062J Mathematics for Computer Science October 3, 2006 Tom Leighton and Ronitt Rubinfeld. Graph Theory III

Social Media Mining. Graph Essentials

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

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

Generalized Induced Factor Problems

Scheduling Home Health Care with Separating Benders Cuts in Decision Diagrams

P versus NP, and More

Chapter 4. Trees. 4.1 Basics

princeton univ. F 13 cos 521: Advanced Algorithm Design Lecture 6: Provable Approximation via Linear Programming Lecturer: Sanjeev Arora

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

CS5314 Randomized Algorithms. Lecture 16: Balls, Bins, Random Graphs (Random Graphs, Hamiltonian Cycles)

Chapter 6: Graph Theory

The Classes P and NP

Trees and Fundamental Circuits

Class One: Degree Sequences

Tetris is Hard: An Introduction to P vs NP

Artificial Intelligence Methods (G52AIM)

Distributed Computing over Communication Networks: Maximal Independent Set

Homework 15 Solutions

MGF 1107 CH 15 LECTURE NOTES Denson. Section 15.1

Data Structures and Algorithms Written Examination

Discrete Mathematics & Mathematical Reasoning Chapter 10: Graphs

The origins of graph theory are humble, even frivolous. Biggs, E. K. Lloyd, and R. J. Wilson)

1. Sorting (assuming sorting into ascending order) a) BUBBLE SORT

Theoretical Computer Science (Bridging Course) Complexity

Graphs and Network Flows IE411 Lecture 1

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

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

Quantum Monte Carlo and the negative sign problem

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

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

The Knapsack Problem. Decisions and State. Dynamic Programming Solution Introduction to Algorithms Recitation 19 November 23, 2011

Advertisement
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