Complexity and Reductions in Problem Solving

lecture 21 complexity and reductions n.w
1 / 27
Embed
Share

Delve into the realm of problem complexity and reductions through discussions on comparing problems, limitations of algorithms, and the concept of reductions in computational problem-solving scenarios.

  • Complexity
  • Reductions
  • Problem Solving
  • Algorithms
  • Comparisons

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Lecture 21 Complexity and Reductions

  2. Outline How do we compare complexity of problems? Why do we care about complexity Na ve comparisons Reductions Easy problems and Hard problems, P and NP Definitions: P and NP Examples of NP problems Polynomial time reductions.

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

  4. 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.

  5. 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?

  6. 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.

  7. 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.

  8. 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.

  9. 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. Median(X) { Sort(X); return X[(X.length+1)/2]; } Runtime of A Runtime of B + Time of Reduction.

  10. Reduction Examples A: Longest increasing subsequence. B: Longest common subsequence. A can be reduced to B, because given a sequence X[], we can first sort it to get Y[] then the LIS of X[] is equal to the LCS of X[] and Y[]. LIS(X) { } Y = MergeSort(X); return LCS(X, Y); Runtime of A Runtime of B + Time of Reduction.

  11. General Recipe for Reduction Reducing A to B. A(X) { } do something call B do something else If we can solve B, we can also solve A. If the additional steps in the program are easy, we can claim A is easier than B. Later we will see a specific type of reductions.

  12. Outline How do we compare complexity of problems? Why do we care about complexity Na ve comparisons Reductions Easy problems and Hard problems, P and NP Definitions: P and NP Examples of NP problems Polynomial time reductions.

  13. 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.

  14. 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?

  15. 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.

  16. NP problems Consider a puzzle like sudoku Given the solution, it is easy to check that it is correct But it can be much harder to find the solution.

  17. 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.

  18. NP problems Verifier: Checking every row, column and square. This is a correct solution. NP problem: does this sudoku have a solution? Prover: Yes, and here is a solution.

  19. Easy to verify problems: NP Example 2: Is there a path from s to t that has cost at most L? If the answer is Yes, the prover 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.

  20. Easy to verify problems: NP Example 3: Is number x a composite number? If the answer is Yes, the prover 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.

  21. Example 4: 3-COLORING 3-COLORING: Check whether there is a way to color vertices of the graph using 3 colors, such that no edge connect two vertices of the same color. input Prover: Yes, the graph can be colored by 3 colors.

  22. Easy to verify problems: NP All decision problems such that we can verify the correctness of a solution in polynomial time. Example: 3-COLORING Prover: Yes, the graph can be colored by 3 colors. Verifier: OK, that is indeed a solution.

  23. 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

  24. Polynomial time reductions A(X) { } Recall: General Reduction do something call B do something else Polynomial time reduction A(X) { } spend polynomial time to prepare an input Y for problem B return B(Y) Can only spend polynomial time Cannot do any post-processing.

  25. Polynomial time reductions Reduce A to B: if there is a polynomial time algorithm that can transform an instance X of problem A to an instance Y of problem B in polynomial time, such that the answers are the same, then this is called a polynomial time reduction. X: instance of A Y: instance of B reduction If answer to X is YES, answer to Y is also YES If answer to X is NO, answer to Y is also NO A is easier, if B can be solved in polynomial time, then A can also be solved in polynomial time.

  26. 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 complete problems can be solved in polynomial time, then P = NP. Theorem: Cook-Levin: Circuit-SAT is NP-complete.

  27. 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.

Related


More Related Content