Lecture 22 Complexity and Reductions

Slides:



Advertisements
Similar presentations
Part VI NP-Hardness. Lecture 23 Whats NP? Hard Problems.
Advertisements

NP-Hard Nattee Niparnan.
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.
S. J. Shyu Chap. 1 Introduction 1 The Design and Analysis of Algorithms Chapter 1 Introduction S. J. Shyu.
Computability and Complexity 13-1 Computability and Complexity Andrei Bulatov The Class NP.
Computational problems, algorithms, runtime, hardness
The Theory of NP-Completeness
Analysis of Algorithms CS 477/677
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Chapter 11: Limitations of Algorithmic Power
Hardness Results for Problems
Programming & Data Structures
MCS312: NP-completeness and Approximation Algorithms
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
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.
CSC 413/513: Intro to Algorithms NP Completeness.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
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.
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
NP-Complete problems.
NP-Completeness (Nondeterministic Polynomial Completeness) Sushanth Sivaram Vallath & Z. Joseph.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 29.
CPS Computational problems, algorithms, runtime, hardness (a ridiculously brief introduction to theoretical computer science) Vincent Conitzer.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Lecture 25 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
1 CPSC 320: Intermediate Algorithm Design and Analysis July 30, 2014.
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.
Great Theoretical Ideas in Computer Science.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The NP class. NP-completeness
NP-Complete Problems.
Chapter 10 NP-Complete Problems.
Computational Complexity Theory
Computational problems, algorithms, runtime, hardness
Richard Anderson Lectures NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Lecture 2-2 NP Class.
Part VI NP-Hardness.
Richard Anderson Lecture 29 NP-Completeness and course wrap-up
Lecture 5 Dynamic Programming
Lecture 5 NP Class.
NP-Completeness Yin Tat Lee
Intro to Theory of Computation
ICS 353: Design and Analysis of Algorithms
Intro to NP Completeness
Richard Anderson Lecture 25 NP-Completeness
Chapter 8 NP and Computational Intractability
1. for (i=0; i < n; i+=2) if (A[i] > A[i+1]) swap(A[i], A[i+1])
Richard Anderson Lecture 30 NP-Completeness
CLASSES P AND NP.
Chapter 11 Limitations of Algorithm Power
Chapter 34: NP-Completeness
NP-completeness The Chinese University of Hong Kong Fall 2008
CPS 173 Computational problems, algorithms, runtime, hardness
NP-Completeness Yin Tat Lee
NP-Completeness Reference: Computers and Intractability: A Guide to the Theory of NP-Completeness by Garey and Johnson, W.H. Freeman and Company, 1979.
P, NP and NP-Complete Problems
P, NP and NP-Complete Problems
Richard Anderson Lecture 25 NP Completeness
Lecture 24 Classical NP-hard Problems
Algorithms CSCI 235, Spring 2019 Lecture 36 P vs
Our old list of problems
RAIK 283 Data Structures & Algorithms
ADVANCED COMPUTATIONAL MODELS AND ALGORITHMS
Lecture 22 Complexity and Reductions
Lecture 23 NP-Hard Problems
Presentation transcript:

Lecture 22 Complexity and Reductions

Recap Algorithms: Design Ideas: Graph Algorithms Linear Program Divide and Conquer Dynamic Programming Greedy Graph Algorithms Shortest Path Minimum Spanning Tree Matching Linear Program

Limitation of Algorithms? Question: What problems are easier to solve using algorithms, what problems cannot be solved using efficient algorithms? I cannot find a fast algorithm for this problem. This problem does not have a fast algorithm.

Comparing problems Question: For two problems A and B, how do we know A is simpler than B? Idea: Best algorithm for A is faster than best algorithm for B. How can we know this even if we don’t know how the best algorithm for A or B?

Idea 1: Special cases If A is a special case of B, then A is simpler than B. Example: A: Shortest path on graphs with no negative edge. B: Shortest path on graphs with general edge weight. Example 2: A: Linear Program in canonical form. B: A general linear program. Problem: cannot compare two problems that are not directly related Also hard to tell whether A is slightly simpler or much simpler.

Idea 2: Similarity in Problem Statement Conjecture: If problems A and B have similar problem statements, they also have similar difficulty. Not true! Example: A: Given graph G with positive edge weights, find the shortest path from s to t that has no duplicate vertex. B: Given graph G with positive edge weights, find the longest path from s to t that has no duplicate vertex. Example 2: A: Color vertices graph with 2 colors, such that all edges connect two vertices of different colors. B: Color vertices graph with 3 colors, such that all edges connect two vertices of different colors.

Reductions A general way of comparing the difficulty of two problems. A can be “reduced to” B, if given a solution to problem B, we can also solve problem A. “Solution to B”: Think of as a magical function that is already implemented, given input to problem B, can return the correct answer.

Reduction Examples A: Find the median of an array. B: Sort an array. A can be reduced to B, because we can first sort the array, and then return the middle element. Runtime of A ≤ Runtime of B + Time of Reduction.

Reduction Examples A: Longest increasing subsequence. B: Longest common subsequence. A can be reduced to B, because given a sequence a[], we can first sort it to get b[] then the LIS of a[] is equal to the LCS of a[] and b[]. Runtime of A ≤ Runtime of B + Time of Reduction.

Reduction Examples A: General Linear Program. B: Linear Program in Canonical Form. A can be reduced to B, because in class we talked about how to convert every linear program into a canonical form. In this case, A≤B, and also B ≤ A (special case) so the two problems are equally hard.

Easy Problems and Hard Problems Easy problem: problems that can be solved in polynomial time. (O(n), O(nlog n), O(n3), … ) Hard problem: problems that (we believe) cannot be solved in polynomial time. Complexity: How hard it is to solve a problem. Complexity class: A set of problems that are “similar” in difficulty.

Decision Problems Problems that have Yes/No answers. Many problems can be converted into decision problems: Shortest Path: Find the shortest path from s to t. Decision version: Is there a path from s to t that has cost at most L? Minimum Spanning Tree Decision version: Is there a spanning tree with cost at most W?

Easy problems: Class P All decision problems that can be solved in polynomial time. These are considered to be easy problems. All problems we covered in this course are in P.

“Easy to verify” problems: NP All decision problems such that we can verify the correctness of a solution in polynomial time. What does it mean to verify? A prover (who may take a long time to run) will provide the verifier an answer and an explanation. Verify: Takes the input, answer and explanation. If the answer is yes, there should exists an explanation that can convince the verifier. If the answer is no, no matter what explanation you provide, the verifier should not be convinced.

“Easy to verify” problems: NP Example 1: Is there a path from s to t that has cost at most L? If the answer is Yes, the algorithm will also give a path. How to verify: Given a path, we can just check 1. It is a path from s to t. 2. The total length is at most L.

“Easy to verify” problems: NP Example 2: Is number x a composite number? If the answer is Yes, the algorithm will give x = yz. How to verify: Given the solution, we can check 1. x = yz 2. y, z are integers between 2 and x.

“Easy to verify” problems: NP Example 3: Color vertices graph with 3 colors, such that all edges connect two vertices of different colors. If the answer is Yes, the algorithm will give the color for each vertex. How to verify: Given the solution, we can check if all edges connect two vertices of different colors.

P vs. NP All problems in P are also in NP. If I can solve the problem, I don’t need an explanation. We don’t know if P = NP, but we believe P is not equal to NP. (Intuition: Solving a problem is harder than setting a problem) NP P

Polynomial time reductions Reduce A to B: if there is a polynomial time algorithm that can transform an instance of problem A to an instance of problem B in polynomial time, such that the answers are the same, then this is called a polynomial time reduction. Corollary: A is “easier” than B. If B can be solved in polynomial time, then A can also be solved in polynomial time, A B reduction

Hard problems: NP complete Hardest problems in NP. If A is in NP, and B is a NP complete problem, then A can be reduced to B. Corollary: If any of the NP-hard problems can be solved in polynomial time, then P = NP. Theorem: Cook-Levin: Circuit-SAT is NP-complete.

Harder problems? There are problems that are not in NP. Example 1: Halting Problem: given the code of a program, check if it will terminate or not. This problem is not even solvable. Example 2: Playing chess: given a chess board with n*n size, with 4n chess pieces, decide whether the first player can always win. This is believed to be PSPACE complete, and very unlikely to be in NP.