CHAPTER 10 P and NP. Algorithm 10.2.2 Crossword Puzzle This algorithm solves a crossword puzzle, represented by a Boolean matrix D[i,j], 1 = i,j = n,

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

NP-Hard Nattee Niparnan.
Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
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.
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 
CHAPTER 11 Coping with NP-completeness. Algorithm Largest Independent Set This algorithm returns α(G), the size of a largest independent set in.
Computability and Complexity 23-1 Computability and Complexity Andrei Bulatov Search and Optimization.
Complexity 15-1 Complexity Andrei Bulatov Hierarchy Theorem.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 21 Instructor: Paul Beame.
Approximation Algorithms Lecture for CS 302. What is a NP problem? Given an instance of the problem, V, and a ‘certificate’, C, we can verify V is in.
1 NP-Completeness Objectives: At the end of the lesson, students should be able to: 1. Differentiate between class P, NP, and NPC 2. Reduce a known NPC.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
88- 1 Chapter 8 The Theory of NP-Completeness P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class.
Chapter 11: Limitations of Algorithmic Power
Complexity ©D.Moshkovitz 1 Paths On the Reasonability of Finding Paths in Graphs.
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.
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.
CSCI 2670 Introduction to Theory of Computing November 29, 2005.
Polynomial-time reductions We have seen several reductions:
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
The Class NP Lecture 39 Section 7.3 Mon, Nov 26, 2007.
Hard problems in computer science Prof. Noah Snavely CS1114
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
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.
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
“One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”
Hamiltonian Path Problem This girl do this presentation. :) Teddy bear work along with me. Jeff help me understand the topic. Are they both cute?
Lecture 25 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
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 CSE 326: Data Structures: Graphs Lecture 23: Wednesday, March 5 th, 2003.
Unit – 5: Backtracking For detail discussion, students are advised to refer the class discussion.
TU/e Algorithms (2IL15) – Lecture 10 1 NP-Completeness, II.
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
NP-Completeness (2) NP-Completeness Graphs 4/13/2018 5:22 AM x x x x x
More NP-Complete and NP-hard Problems
More NP-complete problems
Richard Anderson Lectures NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Lecture 2-2 NP Class.
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness (2) NP-Completeness Graphs 7/23/ :02 PM x x x x
NP-Completeness Proofs
Richard Anderson Lecture 26 NP-Completeness
Hard Problems Introduction to NP
BACKTRACKING- GENERAL METHOD
ICS 353: Design and Analysis of Algorithms
NP-Completeness (2) NP-Completeness Graphs 11/23/2018 2:12 PM x x x x
Richard Anderson Lecture 25 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
NP-Complete Problems.
Prabhas Chongstitvatana
CS154, Lecture 13: P vs NP.
Richard Anderson Lecture 26 NP-Completeness
The Theory of NP-Completeness
More NP-complete problems
CSE 589 Applied Algorithms Spring 1999
Instructor: Aaron Roth
Lecture 24 Classical NP-hard Problems
NP-Completeness (2) NP-Completeness Graphs 7/9/2019 6:12 AM x x x x x
Hamiltonian Circuit (HC) problem
Lecture 23 NP-Hard Problems
Presentation transcript:

CHAPTER 10 P and NP

Algorithm Crossword Puzzle This algorithm solves a crossword puzzle, represented by a Boolean matrix D[i,j], 1 = i,j = n, and a finite set of words W ⊆ Σ *. Σ is the alphabet, and D[i,j] is true if the square is blank and false if it is blocked. We construct the solution in a new matrix S[i,j], 1 = i,j = n. The algorithm returns true if the crossword can be solved. Input Parameters: D, W Output Parameters: None puzzle(D,W) { for i = 1 to n for j = 1 to n if (D[i,j]) S[i,j] = guess(Σ) else S[i,j] = blocked for each word w in S if (w  W) return false return true }

Algorithm Graph k-coloring This algorithm finds a k-coloring of G = (V,E), if there is one, and stores it in the array c. The algorithm returns true if a coloring is found. Input Parameters: G = (V,E), k Output Parameters: None graph_coloring(G,k) { for each v in V c[v] = guess({1,2,...,k}) for each v in V for each w in N(v) if (c[w] == c[v]) return false return true }

Algorithm Hamiltonian Cycle This algorithm finds a Hamiltonian cycle in G = (V,E) if there is one and returns true in that case.

Input Parameter: G = (V,E) Output Parameters: None hamiltonian_cycle(G) { n = |V| for i = 1 to n visited[i] = false for i = 1 to n { c[i] = guess(V) visited[c[i]] = true } c[0] = c[n] // first node is the same as last // check that only edges of G are used for i = 0 to n - 1 if ((c[i],c[i + 1])  E) return false // check that all vertices have been visited for i = 1 to n if (!(visited[i])) return false return true }

Algorithm TSP This algorithm finds a Hamiltonian cycle in G = (V, E, weight) of total weight at most w if there is one and returns true in that case. Input Parameters: G = (V, E, weight), w Output Parameters: None tsp(G,w) { n = |V| for i = 1 to n c[i] = guess(V) c[0] = c[n]...

// check that only edges of G are used, // and compute the total weight of the tour totalweight = 0 for i = 1 to n - 1 if ((c[i],c[i + 1])  E) return false else totalweight = totalweight + weight((c[i],c[i + 1])) // reject tours whose total weight is too large if (totalweight > w) return false // check that all vertices are visited for i = 1 to n visited[i] = false for i = 1 to n visited[c[i]] = true for i = 1 to n if (!(visited[i])) return false return true }

Example graph_coloring(G,k) { for each v in V c[v] = 0 for each v in V { c[v] = guess({1,2,...,k}) for each w in N(v) if (c[w] == c[v]) return false } return true }

Algorithm Satisfiability Witness This algorithm takes as input a CNF formula ϕ on variables x 1,...,x n, and either returns a satisfying assignment for ϕ in the array x or false if there is no such assignment. It assumes that we have an algorithm A that decides whether a formula is satisfiable or not.

Input Parameter: ϕ Output Parameter: x satisfiability_witness( ϕ, x) { if (!(A( ϕ )) return false for i = 1 to n { ψ = ϕ [x i → true] if (A( ϕ )) { x[i] = true ϕ = ψ } else { x[i] = false ϕ = ϕ [x i → false] } return true }