CSC 172 P, NP, Etc. “Computer Science is a science of abstraction – creating the right model for thinking about a problem and devising the appropriate.

Slides:



Advertisements
Similar presentations
NP-Hard Nattee Niparnan.
Advertisements

Polynomial-time reductions We have seen several reductions:
Reducibility Class of problems A can be reduced to the class of problems B Take any instance of problem A Show how you can construct an instance of problem.
What is Intractable? Some problems seem too hard to solve efficiently. Question 1: Does an efficient algorithm exist?  An O(a ) algorithm, where a > 1,
1 NP-completeness Lecture 2: Jan P The class of problems that can be solved in polynomial time. e.g. gcd, shortest path, prime, etc. There are many.
NP and NP Complete. Definitions A problem is in the class P if there is a polynomial time solution to the problem A problem is in the class NP if there.
NP-Completeness Lecture for CS 302. Traveling Salesperson Problem You have to visit n cities You want to make the shortest trip How could you do this?
The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
Complexity Theory CSE 331 Section 2 James Daly. Reminders Project 4 is out Due Friday Dynamic programming project Homework 6 is out Due next week (on.
The Theory of NP-Completeness
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Computational Complexity CSC 172 SPRING 2002 LECTURE 27.
Analysis of Algorithms CS 477/677
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Toward NP-Completeness: Introduction Almost all the algorithms we studies so far were bounded by some polynomial in the size of the input, so we call them.
P, NP, and NP-Complete Suzan Köknar-Tezel.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
NP-Complete Problems CSC 331: Algorithm Analysis NP-Complete Problems.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
Prabhas Chongstitvatana1 NP-complete proofs The circuit satisfiability proof of NP- completeness relies on a direct proof that L  p CIRCUIT-SAT for every.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
CSC 413/513: Intro to Algorithms NP Completeness.
Polynomial-time reductions We have seen several reductions:
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA.
Complexity Non-determinism. NP complete problems. Does P=NP? Origami. Homework: continue on postings.
Techniques for Proving NP-Completeness Show that a special case of the problem you are interested in is NP- complete. For example: The problem of finding.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness and course wrap up.
NP-Complete problems.
Design and Analysis of Algorithms - Chapter 101 Our old list of problems b Sorting b Searching b Shortest paths in a graph b Minimum spanning tree b Primality.
Limits to Computation How do you analyze a new algorithm? –Put it in the form of existing algorithms that you know the analysis. –For example, given 2.
NP-Completeness (Nondeterministic Polynomial Completeness) Sushanth Sivaram Vallath & Z. Joseph.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NPC.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 8: Crash Course in Computational Complexity.
CSC 413/513: Intro to Algorithms
Introduction to NP-Completeness Tahir Azim. The Downside of Computers Many problems can be solved in linear time or polynomial time But there are also.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 30, 2014.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
CSC 172 P, NP, Etc.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The Theory of NP-Completeness
More NP-Complete and NP-hard Problems
Richard Anderson Lecture 26 NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
The Theory of NP-Completeness
Our old list of problems
RAIK 283 Data Structures & Algorithms
Presentation transcript:

CSC 172 P, NP, Etc

“Computer Science is a science of abstraction – creating the right model for thinking about a problem and devising the appropriate mechanizable technique to solve it.” Aho & Ullman (1995)

The process of abstraction You can solve problems by wiring up special purpose hardware (hand calculator) Turing showed that you could abstract hardware configurations Von Neumann showed that you could abstract away from the hardware (machine languages) High level languages are an abstraction of low level languages (JAVA/C++ rather than SML)

The process of abstraction Data structures are an abstractions in high level languages (“mystack.push(myobject)”) So, now we can talk about solutions to whole problems “Similar” problems with “similar” solutions constitute the next level of abstraction

Hard, Harder, Impossible  Some well-formed computational problems don't have computational solution.  They are “undecidable”. Trick: liar's paradox: “This sentence is false”.  Halts?(x) is a subroutine that is T or F if x (a program) halts or loops.  Oops(x) is if Halts?(x) then loop-forever() else halt.  Oops(Oops) ??

Some Definitions  Exponential time: you have to test every possibility O(k n )  Polynomial time: you have some clever algorithm O(n k ) Note even n 100 is better than exponential

 P: A problem that can be solved quickly (in polynomial time) O(n c )  NP: A problem whose solution can be checked for correctness in polynomial time.  NP-hard: A problem such that every problem in NP reduces to it. (Not in NP)  NP-complete (NPC): A problem that is both NP hard and in NP

 P: A problem that can be solved quickly (in polynomial time) O(n c )  NP: A problem whose solution can be checked for correctness in polynomial time.  NP-hard: A problem such that every problem in NP reduces to it. (Not in NP)  NP-complete (NPC): A problem that is both NP hard and in NP

The class of problems “P” “P” stands for “Polynomial” The class “P” is the set of problems that have polynomial time solutions Some problems have solutions that run in O(n c ) time testing for cycles, MWST, Conn. Comps, shortest path, simple sorting,....

Not in the class of problems “P”? On the other hand, some problems seem to take time that is exponential O(2 n ) or worse TSP, satisfiability, graph coloring

Famous Examples  Travelling Salesman Prob: In undirected weighted graph find path starting and ending at specified vertex, visiting each vertex once, costing <= K.  Satisfiability: e.g. what a, b, c, d, e values make (a v b v ~c)^(d v ~a ve)^(~c v b v d)^(c v ~d v e) true? (3-SAT)  How many colors needed to color graph vertices so no nbrs have same color? How color (= sudoku)?

Same problem if polynomially reducible Assume I have boolean fn satisfiable(String expression) How do I write tautology(String expression)

Easy Conversion tautology(exp) = no var. assts such that satisfiable(exp) is false.

The class NP “NP” stands for “Nondeterministic Polynomial” Nondeterministic computation: “guess” or “parallelize” A problem can be solved in nondeterministic polynomial time if: given a guess at a solution for some instance of size n we can check that the guess is correct in polynomial time (i.e. the check runs O(n c ))

NP takes P time to Check  TSP: does path hit all vertices, cost <= K? linear.  SAT: evaluate the boolean expression with constant (0,1) values: linear.  Colorability: check all edges for diff. colored ends. linear.  Hamiltonian Path: path hits all vertices? linear.

P NP NPP P  NP

NPC NPC stands for “NP-complete” Some problems in NP are also in P -they can be solved as well as checked in O(n c ) time Others, appear not to be solvable in polynomial time There is no proof that they cannot be solved in polynomial time But, we have the next best thing to such proof A theory that says many of these problems are as hard as any in NP We call these “NP-complete problems”

Not sure? We work to prove equivalence of NPC problems If we could solve one of them in O(n c ) time then all would be solvable in polynomial time (P == NP) What do we have? Since the NP-complete problems include many that have been worked on for centuries, there is strong evidence that all NP-complete problems really require exponential time to solve.

Reductions The way a problem is proved NP-complete is to “reduce” a known NP-complete problem to it We reduce a problem A to a problem B by devising a solution that uses only a polynomial amount of time (to convert the data, make the correspondence) plus a call to a method that solves B

Easiest NPC Problem?  Partition problem: partition list of integers into 2 parts such that sum(part1) = sum(part2)  (3,1,1,2,2,1) -> (1,1,1,2) and (2,3).  Version of subset-sum problem (is there a subset of a list of ints that sums to zero?), Also NPC.  Very good dynamic program and not bad greedy approaches. hence “easy”.

Back to Graphs By way of example of a class of problems consider Cliques & Independent Sets in graphs

Cliques A complete sub-graph of an undirected graph A set of nodes of some graph that has every possible edge The clique problem: Given a graph G and an integer k, is there a clique of at least k nodes?

Example

AB CD EFHG

AB CD EFHG

AB CD EFHG K == 4 ABEF CGHD

Independent Set Subset S of the nodes of an undirected graph such that there is no edge between any two members of S The independent set problem given a graph G and an integer k, is there an independent set with at least k nodes (Application: scheduling final exams) nodes == courses, edges mean that courses have one student in common. Any guesses on how large the graph would be for UR?

Example independent set AB CD EFHG K == 2 AC AD AG AH B(D,G,H) Etc..

Checking Solutions Clique, IS, colorability are examples of hard to find solutions “find a clique of n nodes” But, it’s easy (polynomial time) to check a proposed solution.

Checking Check a proposed clique by checking for the existence of the edges between the k nodes Check for an IS by checking for the non- existence of an edge between any two nodes in the proposed set Check a proposed coloring by examining the ends of all the edges in the graph

Checking Check a proposed clique by checking for the existence of the edges between the k nodes Check for an IS by checking for the non- existence of an edge between any two nodes in the proposed set Check a proposed coloring by examining the ends of all the edges in the graph

Same Problem Reductions Clique to IS Given a graph G and an integer k we want to know if there is a clique of size k in G 1. Construct a graph H with the same set of nodes as G and an edge wherever G does not have edges 2. An independent set in H is a clique in G 3. Use the “IS” method on H and return its answer

Same Problem Reductions IS to Clique Given a graph G and an integer k we want to know if there is an IS of size k in G 1. Construct a graph H with the same set of nodes as G and an edge wherever G does not have edges 2. An independent set in H is a clique in G 3. Use the “clique” method on H and return its answer

Example AB CD EG

AB CD EG

AB CD EG

AB C D EG

A BC D EG

A BC D EG

A BC D EG AB CD EG

Hamiltonian cycle from TSP Make complete graph from input graph, give original edges cost 1, added edges cost 2, and if there were K original edges solve TSP for K.