Analysis of Algorithms

Slides:



Advertisements
Similar presentations
Reductions Complexity ©D.Moshkovitz.
Advertisements

Introduction to Algorithms NP-Complete
1 P, NP, and NP-Complete Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
Problems and Their Classes
NP-Hard Nattee Niparnan.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Limitation of Computation Power – P, NP, and NP-complete
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.
The Theory of NP-Completeness
CPE702 Complexity Classes Pruet Boonma Department of Computer Engineering Chiang Mai University Based on Material by Jenny Walter.
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
Analysis of Algorithms CS 477/677
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Chapter 11: Limitations of Algorithmic Power
P, NP, and NP-Complete Suzan Köknar-Tezel.
NP and NP- Completeness Bryan Pearsaul. Outline Decision and Optimization Problems Decision and Optimization Problems P and NP P and NP Polynomial-Time.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
Programming & Data Structures
MCS312: NP-completeness and Approximation Algorithms
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.
1 NP-Completeness Poly time algorithm: input size n (in some encoding), worst case running time – O(n c ) for some constant c. Three classes of problems.
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
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.
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.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
NP-Complete problems.
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.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
CSC 413/513: Intro to Algorithms
Optimization/Decision Problems Optimization Problems – An optimization problem is one which asks, “What is the optimal solution to problem X?” – Examples:
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.
34.NP Completeness. Computer Theory Lab. Chapter 34P.2.
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
The NP class. NP-completeness
NP-Completeness (2) NP-Completeness Graphs 4/13/2018 5:22 AM x x x x x
NP-Complete Problems.
NP-completeness Ch.34.
Chapter 10 NP-Complete Problems.
Richard Anderson Lectures NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Advanced Algorithms Analysis and Design
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
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
Chapter 34: NP-Completeness
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
Prabhas Chongstitvatana
The Theory of NP-Completeness
NP-Completeness (2) NP-Completeness Graphs 7/9/2019 6:12 AM x x x x x
Presentation transcript:

Analysis of Algorithms NP & NP-Complete Prof. Muhammad Saeed

3. NP-Complete (NPC, NP-C) Classes Of Problems 1. P 2. NP 3. NP-Complete (NPC, NP-C) Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page …… Classes Of Problems P: Consists of those problems that are solvable in polynomial time. More specifically, they are problems that can be solved in time O(nk) for some constant k, where n is the size of the input to the problem. They are called easy or tractable. Problems that require superpolynomial time as being intractable, or hard. NP: Consists of those problems that are verifiable in polynomial time, it means if we were somehow given a ‘certificate’ of a solution, then we could verify that the certificate is correct in polynomial time in the size of the input to the problem. Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page NPC (NP-Complete): Problems in NP and as hard as any problem in NP. No polynomial-time algorithm has yet been discovered for an NP-complete problem, nor has anyone yet been able to prove that no polynomial-time algorithm can exist for any one of them. Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page Complexity Class P Deterministic in nature Solved by conventional computers in polynomial time O(1) Constant O(log n) Sub-linear O(n) Linear O(n log n) Nearly Linear O(n2) Quadratic O(nk) k-Polynomial Polynomial upper and lower bounds Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page Shortest vs. longest simple paths: Even with negative edge weights, we can find shortest paths from a single source in a directed graph G = (V, E) in O(V E) time. Finding a longest simple path between two vertices is difficult, however. Merely determining whether a graph contains a simple path with at least a given number of edges is NP-complete. Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page Euler tour vs. hamiltonian cycle: An Euler tour of a connected, directed graph G = (V, E) is a cycle that traverses each edge of G exactly once, although it may visit a vertex more than once. We can determine whether a graph has an Euler tour in only O(E) time and, in fact, we can find the edges of the Euler tour in O(E) time. A hamiltonian cycle of a directed graph G = (V, E) is a simple cycle that contains each vertex in V. Determining whether a directed graph has a hamiltonian cycle is NP-complete. determining whether an undirected graph has a hamiltonian cycle is NP-complete. Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page 2-CNF satisfiability vs. 3-CNF satisfiability: A boolean formula contains variables whose values are 0 or 1; boolean connectives such as ∧ (AND), ∨ (OR), and ¬ (NOT); and parentheses. A boolean formula is satisfiable if there is some assignment of the values 0 and 1 to its variables that causes it to evaluate to 1. A boolean formula is in k-conjunctive normal form, or k-CNF, if it is the AND of clauses of ORs of exactly k variables or their negations. For example, the boolean formula (x1 ∨ ¬x2) ∧ (¬x1 ∨ x3) ∧ (¬x2 ∨ ¬x3) is in 2-CNF. (It has the satisfying assignment x1 = 1, x2 = 0, x3 = 1.) There is a polynomial-time algorithm to determine whether a 2-CNF formula is satisfiable, a 3-CNF formula is satisfiable is NP-complete. Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page Relation among P, NP, NPC P  NP (Sure) NPC  NP (sure) P = NP (or P  NP, or P  NP) ??? NPC = NP (or NPC  NP, or NPC  NP) ??? P  NP: one of the deepest, most perplexing open research problems in (theoretical) computer science since 1971. Any problem in P is also in NP, since if a problem is in P then we can solve it in polynomial time without even being given a certificate. Most theoretical computer scientists believe that NPC is intractable (i.e., hard, and P  NP). Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page View of Theoretical Computer Scientists on P, NP, NPC NPC P NP P  NP, NPC  NP, P  NPC =  Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page Why discussion on NPC If a problem is proved to be NPC, a good evidence for its intractability (hardness). Not waste time on trying to find efficient algorithm for it Instead, focus on design approximate algorithm or a solution for a special case of the problem Some problems looks very easy on the surface, but in fact, is hard (NPC). Analysis OF Algorithms NP-NP-Complete Page

Decision VS. Optimization Problems Decision problem: solving the problem by giving an answer “YES” or “NO” Optimization problem: solving the problem by finding the optimal solution. Examples: SHORTEST-PATH (optimization) Given G, u,v, find a path from u to v with fewest edges. PATH (decision) Given G, u,v, and k, whether exist a path from u to v consisting of at most k edges. Analysis OF Algorithms NP-NP-Complete Page

Decision VS. Optimization Problems (Cont.) Decision is easier (i.e., no harder) than optimization If there is an algorithm for an optimization problem, the algorithm can be used to solve the corresponding decision problem. Example: SHORTEST-PATH for PATH If optimization is easy, its corresponding decision is also easy. Or in another way, if provide evidence that decision problem is hard, then the corresponding optimization problem is also hard. NPC is confined to decision problem. (also applicable to optimization problem.) Another reason is that: easy to define reduction between decision problems. Analysis OF Algorithms NP-NP-Complete Page

(Poly) reduction between decision problems Problem (class) and problem instance Instance  of decision problem A and instance  of decision problem B A reduction from A to B is a transformation with the following properties: The transformation takes poly time The answer is the same (the answer for  is YES if and only if the answer for  is YES). Analysis OF Algorithms NP-NP-Complete Page

Implication of (poly) reduction YES   YES (Poly) Reduction Algorithm for B NO Decision algorithm for A NO If decision algorithm for B is poly, so does A. A is no harder than B (or B is no easier than A) 2. If A is hard (e.g., NPC), so does B. 3. How to prove a problem B to be NPC ?? (at first, prove B is in NP, which is generally easy.) 3.1 find a already proved NPC problem A Question: What is and how to prove the first NPC problem? Circuit-satisfiability problem. Analysis OF Algorithms NP-NP-Complete Page

Travelling Salesman Problem (TSP) For each two cities, an integer cost is given to travel from one of the two cities to the other. The salesperson wants to make a minimum cost circuit visiting each city exactly once. Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page Circuit-SAT Logic Gates 1 1 1 NOT 1 1 OR 1 1 1 AND Take a Boolean circuit with a single output node and ask whether there is an assignment of values to the circuit’s inputs so that the output is “1” Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page Two instances of circuit satisfiability problems Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page Knapsack 5 6 2 3 4 7 1 L s Given s and w can we translate a subset of rectangles to have their bottom edges on L so that the total area of the rectangles touching L is at least w? Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page 5-Clique Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page Vertex Cover A graph and its complement. Note that there is a 4-clique (consisting of vertices a, b, d, and f) in the graph on the left. Note also that the vertices not in this clique (namely c and e) do form a cover for the complement of this graph (which appears on the right). Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page The Halting Problem Given an algorithm A and an input I, will the algorithm reach a stopping place? In general, we cannot solve this problem in finite time. loop exit if (x = 1) if (even(x)) then x  x div 2 else x  3 * x + 1 endloop Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page Hamiltonian Path Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page Euler tour vs. hamiltonian cycle: An Euler tour of a connected, directed graph G = (V, E) is a cycle that traverses each edge of G exactly once, although it may visit a vertex more than once. We can determine whether a graph has an Euler tour in only O(E) time and, in fact, we can find Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page

Analysis OF Algorithms NP-NP-Complete Page END Analysis OF Algorithms NP-NP-Complete Page