Analysis of Algorithms CS 477/677

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

NP-Hard Nattee Niparnan.
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Concept of Completeness and hardness for a complexity class Definition.
The Theory of NP-Completeness
CPE702 Complexity Classes Pruet Boonma Department of Computer Engineering Chiang Mai University Based on Material by Jenny Walter.
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
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.
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
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
Chapter 11: Limitations of Algorithmic Power
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.
Complexity Issues Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
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
Chapter 11 Limitations of Algorithm Power. Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples:
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
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.
Lecture 30. P, NP and NP Complete Problems 1. Recap Data compression is a technique to compress the data represented either in text, audio or image form.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
CSC 413/513: Intro to Algorithms NP Completeness.
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.
NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA.
CSE 3813 Introduction to Formal Languages and Automata Chapter 14 An Introduction to Computational Complexity These class notes are based on material from.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
P, NP, and Exponential Problems Should have had all this in CS 252 – Quick review Many problems have an exponential number of possibilities and we can.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
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.
Unit 9: Coping with NP-Completeness
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-Complete Problems Algorithm : Design & Analysis [23]
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.
NP-Algorithms Tractable vs Intractable Some problems are intractable: as they grow large, we are unable to solve them in reasonable time.
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.
NP Completeness Piyush Kumar. Today Reductions Proving Lower Bounds revisited Decision and Optimization Problems SAT and 3-SAT P Vs NP Dealing with NP-Complete.
CSC 413/513: Intro to Algorithms
Young CS 331 D&A of Algo. NP-Completeness1 NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
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.
COMPLEXITY. Satisfiability(SAT) problem Conjunctive normal form(CNF): Let S be a Boolean expression in CNF. That is, S is the product(and) of several.
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.
Advanced Algorithms NP-hard and NP-Complete Problems Instructor: Saeid Abrishami Ferdowsi University of Mashhad.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
NP-Complete Problems.
NP-completeness Ch.34.
Chapter 10 NP-Complete Problems.
Advanced Algorithms Analysis and Design
ICS 353: Design and Analysis of Algorithms
Chapter 11 Limitations of Algorithm Power
NP-Complete Problems.
NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979.
RAIK 283 Data Structures & Algorithms
Presentation transcript:

Analysis of Algorithms CS 477/677 NP-Completeness Instructor: George Bebis Chapter 34

NP-Completeness So far we’ve seen a lot of good news! Such-and-such a problem can be solved quickly (i.e., in close to linear time, or at least a time that is some small polynomial function of the input size) NP-completeness is a form of bad news! Evidence that many important problems can not be solved quickly. NP-complete problems really come up all the time!

Why should we care? Knowing that they are hard lets you stop beating your head against a wall trying to solve them… Use a heuristic: come up with a method for solving a reasonable fraction of the common cases. Solve approximately: come up with a solution that you can prove that is close to right. Use an exponential time solution: if you really have to solve the problem exactly and stop worrying about finding a better solution.

Optimization & Decision Problems Given an input and a question regarding a problem, determine if the answer is yes or no Optimization problems Find a solution with the “best” value Optimization problems can be cast as decision problems that are easier to study E.g.: Shortest path: G = unweighted directed graph Find a path between u and v that uses the fewest edges Does a path exist from u to v consisting of at most k edges?

Algorithmic vs Problem Complexity The algorithmic complexity of a computation is some measure of how difficult is to perform the computation (i.e., specific to an algorithm) The complexity of a computational problem or task is the complexity of the algorithm with the lowest order of growth of complexity for solving that problem or performing that task. e.g. the problem of searching an ordered list has at most lgn time complexity. Computational Complexity: deals with classifying problems by how hard they are.

Class of “P” Problems Class P consists of (decision) problems that are solvable in polynomial time Polynomial-time algorithms Worst-case running time is O(nk), for some constant k Examples of polynomial time: O(n2), O(n3), O(1), O(n lg n) Examples of non-polynomial time: O(2n), O(nn), O(n!)

Tractable/Intractable Problems Problems in P are also called tractable Problems not in P are intractable or unsolvable Can be solved in reasonable time only for small inputs Or, can not be solved at all Are non-polynomial algorithms always worst than polynomial algorithms? - n1,000,000 is technically tractable, but really impossible - nlog log log n is technically intractable, but easy

Example of Unsolvable Problem Turing discovered in the 1930’s that there are problems unsolvable by any algorithm. The most famous of them is the halting problem Given an arbitrary algorithm and its input, will that algorithm eventually halt, or will it continue forever in an “infinite loop?”

Examples of Intractable Problems

Intractable Problems Can be classified in various categories based on their degree of difficulty, e.g., NP NP-complete NP-hard Let’s define NP algorithms and NP problems …

Nondeterministic and NP Algorithms Nondeterministic algorithm = two stage procedure: Nondeterministic (“guessing”) stage: generate randomly an arbitrary string that can be thought of as a candidate solution (“certificate”) Deterministic (“verification”) stage: take the certificate and the instance to the problem and returns YES if the certificate represents a solution NP algorithms (Nondeterministic polynomial) verification stage is polynomial

Class of “NP” Problems Class NP consists of problems that could be solved by NP algorithms i.e., verifiable in polynomial time If we were given a “certificate” of a solution, we could verify that the certificate is correct in time polynomial to the size of the input Warning: NP does not mean “non-polynomial”

E.g.: Hamiltonian Cycle Given: a directed graph G = (V, E), determine a simple cycle that contains each vertex in V Each vertex can only be visited once Certificate: Sequence: v1, v2, v3, …, v|V| hamiltonian not hamiltonian

Is P = NP? Any problem in P is also in NP: P  NP The big (and open question) is whether NP  P or P = NP i.e., if it is always easy to check a solution, should it also be easy to find a solution? Most computer scientists believe that this is false but we do not have a proof … P NP

NP-Completeness (informally) NP-complete problems are defined as the hardest problems in NP Most practical problems turn out to be either P or NP-complete. Study NP-complete problems … P NP-complete NP

Reductions Reduction is a way of saying that one problem is “easier” than another. We say that problem A is easier than problem B, (i.e., we write “A  B”) if we can solve A using the algorithm that solves B. Idea: transform the inputs of A to inputs of B f Problem B   yes no Problem A

Polynomial Reductions Given two problems A, B, we say that A is polynomially reducible to B (A p B) if: There exists a function f that converts the input of A to inputs of B in polynomial time A(i) = YES  B(f(i)) = YES

NP-Completeness (formally) A problem B is NP-complete if: (1) B  NP (2) A p B for all A  NP If B satisfies only property (2) we say that B is NP-hard No polynomial time algorithm has been discovered for an NP-Complete problem No one has ever proven that no polynomial time algorithm can exist for any NP-Complete problem P NP-complete NP

Implications of Reduction Problem B   yes no Problem A - If A p B and B  P, then A  P - if A p B and A  P, then B  P

Proving Polynomial Time Polynomial time algorithm to decide A f Polynomial time algorithm to decide B   yes no Use a polynomial time reduction algorithm to transform A into B Run a known polynomial time algorithm for B Use the answer for B as the answer for A

Proving NP-Completeness Theorem: If A is NP-Complete and A p B  B is NP-Hard In addition, if B  NP  B is NP-Complete Proof: Assume that B  P Since A p B  A  P contradiction!

Proving NP-Completeness In Practice Prove that the problem B is in NP A randomly generated string can be checked in polynomial time to determine if it represents a solution Show that one known NP-Complete problem can be transformed to B in polynomial time No need to check that all NP-Complete problems are reducible to B

Revisit “Is P = NP?” Theorem: If any NP-Complete problem can be solved in polynomial time  then P = NP. P NP-complete NP

P & NP-Complete Problems Shortest simple path Given a graph G = (V, E) find a shortest path from a source to all other vertices Polynomial solution: O(VE) Longest simple path Given a graph G = (V, E) find a longest path from a source to all other vertices NP-complete

P & NP-Complete Problems Euler tour G = (V, E) a connected, directed graph find a cycle that traverses each edge of G exactly once (may visit a vertex multiple times) Polynomial solution O(E) Hamiltonian cycle G = (V, E) a connected, directed graph find a cycle that visits each vertex of G exactly once NP-complete

Satisfiability Problem (SAT) Satisfiability problem: given a logical expression , find an assignment of values (F, T) to variables xi that causes  to evaluate to T  =x1   x2  x3   x4 SAT was the first problem shown to be NP-complete!

CFN Satisfiability CFN is a special case of SAT  is in “Conjuctive Normal Form” (CNF) “AND” of expressions (i.e., clauses) Each clause contains only “OR”s of the variables and their complements E.g.:  = (x1  x2)  (x1   x2)  ( x1   x2) clauses

3-CNF Satisfiability A subcase of CNF problem: E.g.: Contains three clauses E.g.:  = (x1  x1  x2)  (x3  x2  x4)  (x1  x3   x4) 3-CNF is NP-Complete Interestingly enough, 2-CNF is in P!

Clique Clique Problem: Optimization problem: Decision problem: Undirected graph G = (V, E) Clique: a subset of vertices in V all connected to each other by edges in E (i.e., forming a complete graph) Size of a clique: number of vertices it contains Optimization problem: Find a clique of maximum size Decision problem: Does G have a clique of size k? Clique(G, 2) = YES Clique(G, 3) = NO Clique(G, 3) = YES Clique(G, 4) = NO

Clique Verifier Given: an undirected graph G = (V, E) Problem: Does G have a clique of size k? Certificate: A set of k nodes Verifier: Verify that for all pairs of vertices in this set there exists an edge in E

3-CNF p Clique Idea: Construct a graph G such that  is satisfiable only if G has a clique of size k

NP-naming convention NP-complete - means problems that are 'complete' in NP, i.e. the most difficult to solve in NP NP-hard - stands for 'at least' as hard as NP (but not necessarily in NP); NP-easy - stands for 'at most' as hard as NP (but not necessarily in NP); NP-equivalent - means equally difficult as NP, (but not necessarily in NP);

Examples NP-complete and NP-hard problems