CSCE350 Algorithms and Data Structure

Slides:



Advertisements
Similar presentations
1 P, NP, and NP-Complete Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
Advertisements

Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Polynomial-time reductions We have seen several reductions:
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,
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 
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
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 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
P, NP, and NP-Complete Suzan Köknar-Tezel.
1 The Theory of NP-Completeness 2 NP P NPC NP: Non-deterministic Polynomial P: Polynomial NPC: Non-deterministic Polynomial Complete P=NP? X = P.
1 UNIT -6 P, NP, and NP-Complete. 2 Tractability u Some problems are intractable: as they grow large, we are unable to solve them in reasonable time u.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
1 CSC 421: Algorithm Design & Analysis Spring 2013 Complexity & Computability  lower bounds on problems brute force, decision trees, adversary arguments,
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:
A. Levitin “Introduction to the Design & Analysis of Algorithms,” 3rd ed., Ch. 11 ©2012 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved.
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.
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.
CSC 413/513: Intro to Algorithms NP Completeness.
Polynomial-time reductions We have seen several reductions:
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
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.
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.
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
CSCE350 Algorithms and Data Structure Lecture 19 Jianjun Hu Department of Computer Science and Engineering University of South Carolina
Design and Analysis of Algorithms - Chapter 101 Our old list of problems b Sorting b Searching b Shortest paths in a graph b Minimum spanning tree b Primality.
NP-Complete Problems Algorithm : Design & Analysis [23]
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
Fundamentals of Informatics Lecture 14 Intractability and NP-completeness Bas Luttik.
LIMITATIONS OF ALGORITHM POWER
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
1 CSC 421: Algorithm Design & Analysis Spring 2014 Complexity & lower bounds  brute force  decision trees  adversary arguments  problem reduction.
Lecture 25 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
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.
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.
1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e)
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.
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
Chapter 10 NP-Complete Problems.
Lecture 2-2 NP Class.
Hard Problems Introduction to NP
Analysis and design of algorithm
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.
P, NP and NP-Complete Problems
The Theory of NP-Completeness
CSE 589 Applied Algorithms Spring 1999
P, NP and NP-Complete Problems
Our old list of problems
RAIK 283 Data Structures & Algorithms
Presentation transcript:

CSCE350 Algorithms and Data Structure Lecture 18 Jianjun Hu Department of Computer Science and Engineering University of South Carolina 2009.11.

Announcement Thanksgiving………… One final homework (for preparing final exam) 60-70

Chapter 10: Limitations of Algorithm Power Basic Asymptotic Efficiency Classes 1 constant log n logarithmic n linear n log n n2 quadratic n3 cubic 2n exponential n! factorial

Polynomial-Time Complexity Polynomial-time complexity: the complexity of an algorithm is with a fixed degree b>0. If a problem can be solved in polynomial time, it is usually considered to be theoretically tractable in current computers. When an algorithm’s complexity is larger than polynomial, i.e., exponential, theoretically it is considered to be too expensive to be useful – intractable This may not exactly reflect it’s usability in practice!

List of Problems Sorting Searching Shortest paths in a graph Minimum spanning tree Primality testing Traveling salesman problem Knapsack problem Chess Towers of Hanoi … These were discussed in the first lecture. At this point, the claims made then about “efficient” algorithms can be discussed in more concrete terms. Before launching into this lecture, I usually read to my students the introductory whimsical example from Garey and Johnson “Computers and Intractability”, while showing overhead transparencies of their cartoons. These are not reproduced here because it would require copyright clearance.

Lower Bound Problem A can be solved by algorithms a1, a2,…, ap Problem B can be solved by algorithms b1, b2,…, bq We may ask Which algorithm is more efficient? This makes more sense when the compared algorithms solve the same problem Which problem is more complex? We may compare the complexity of the best algorithm for A and the best algorithm for B For each problem, we want to know the lower bound: the best possible algorithm’s efficiency for a problem  Ω(.) Tight lower bound: we have found an algorithm of the this lower-bound complexity

Trivial Lower Bound Many problems need to ‘read’ all the necessary items and write the ‘output’ Their sizes provide a trivial lower bound Example: Generate all permutations of n distinct items  Ω(n!) Why? Is this a tight lower bound? Evaluate the polynomial at a given x  Ω(n), because of the input size. Is this tight?

Another Example Multiplying two nxn matrices  Ω(n2) because we need to process 2n2 elements and output n2 elements We do not know whether this is tight Many trivial lower bounds are too low to be useful TSP  Ω(n2) because its input is n(n-1)/2 intercity distance and output is n+1 city in sequence There is no known polynomial-time algorithm to solve it Trivial lower bound sometime have problems We do not need to process all the input elements For example: searching an element in a sorted array. What is its complexity?

Information-Theoretic Arguments This approach seeks to establish a lower bound based on the amount of information it has to produce Recall the problem of guess the number from 1..n by asking ‘yes/no’ questions Fundamentally, it is a coding problem. If the input number can be encoded into m bits, each ‘yes/no’ question just resolve one bit and therefore, the lower bound is m We know that m=log2n We have also shown its relation to decision tree. We will apply the decision tree to find the lower bound for several other problems

Find the Smallest from three numbers using comparison Leaves in the decision tree is the possible output. The output size is at least 3 (maybe larger than 3) here Complexity: the height of this decision tree Given l leaves, the height of the binary tree is at least

Decision Tree for Sorting Algorithms The number of leaves: n! The lower bound: log n!  n log2n. Is this tight? Selection Sort

Decision Tree for Searching a Sorted Array Decision tree for binary search in a four-element array # of leaves for n elements 2n+1 lower bound:  Ω(logn)

P, NP, and NP-Complete Problems As we discussed, problems that can be solved in polynomial time are usually called tractable and the problems that cannot be solved in polynomial time are called intractable, now Is there a polynomial-time algorithm that solves the problem? Possible answers: yes no because it can be proved that all algorithms take exponential time because it can be proved that no algorithm exists at all to solve this problem don’t know don’t know, but if such algorithm were to be found, then it would provide a means of solving many other problems in polynomial time

Types of problems Optimization problem: construct a solution that maximizes or minimizes some objective function Decision problem: answer yes/no to a question Many problems will have decision and optimization versions. Eg: Traveling Salesman Problem optimization: find Hamiltonian cycle of minimum weight decision: Is there a Hamiltonian cycle of weight < k

Some More problems Partition: Given n positive integers, determine whether it is possible to partition them into two disjoint subsets with the same sum Bin packing: given n items whose sizes are positive rational numbers not larger than 1, put them into the smallest number of bins of size 1 Graph coloring: For a given graph find its chromatic number, i.e., the smallest number of colors that need to be assigned to the graph’s vertices so that no two adjacent vertices are assigned the same color CNF satisfiability: Given a boolean expression in conjunctive normal form (conjunction of disjunctions of literals), is there a truth assignment to the variables that makes the expression true?

The class P P: the class of decision problems that are solvable in O(p(n)), where p(n) is a polynomial on n Why polynomial? if not, very inefficient nice closure properties machine independent in a strong sense

The class NP NP: the class of decision problems that are solvable in polynomial time on a nondeterministic machine (A determinstic computer is what we know) A nondeterministic computer is one that can “guess” the right answer or solution Thus NP can also be thought of as the class of problems whose solutions can be verified in polynomial time; or that can be solved in polynomial time on a machine that can pursue infinitely many paths of the computation in parallel Note that NP stands for “Nondeterministic Polynomial-time”

Non-deterministic computer 00 01 10 11 00 01 10 11

Example: Conjunctive Normal Form (CNF) Satisfiability This problem is in NP. Nondeterministic algorithm: Guess truth assignment Check assignment to see if it satisfies CNF formula Example: (Boolean operation) Truth assignments: Checking phase: Θ(n)

Where Are We Now? Exhibited nondeterministic poly-time algorithm for CNF- satisfiability CNF-sat is in NP Similar algorithms can be found for TPS, HC, Partition, etc proving that these problems are also in NP All the problems in P can also be solved in this manner (but no guessing is necessary), so we have: P ⊆ NP Big question: P = NP ?

NP-Complete problems A decision problem D is NP-complete iff D ∈ NP every problem in NP is polynomial-time reducible to D Cook’s theorem (1971): CNF-sat is NP-complete Other NP-complete problems obtained through polynomial- time reductions of known NP-complete problems The class of NP-complete problems is denoted NPC

Polynomial Reductions A decision problem D1 is said to be polynomial reducible to a decision problem D2 if there exists a function t that transforms instances of D1 to instances of D2 such that t maps all yes instances of D1 to yes instances of D2 and all no instances of D1 to no instances of D2 t is computable by a polynomial-time algorithm If D2 can be solved in polynomial time  D1 can be solved in polynomial time

Polynomial Reductions Example: Polynomial-time reduction of HC-Hamiltonian cycle to decision version of TPS (TPS with total distance no larger than k?) given integer distance What does this prove? HC is harder or easier than TPS decision? HC is NPC  TPS(D) is NPC? or TPS(D) is NPC  HC is NPC? y 1 y x x 2 1 2 1 v v u u 1 Of course, both directed and undirected HC are in NPC. Point out also that undirected HC can easily be reduced to directed HC. This is the difficult direction. Poly-time reduction of directed to undirected shows that directed is no harder than undirected. Thus the answer is the first of the two options given (if NPC for directed then also NPC for undirected)

To Prove a Decision Problem is in NPC Prove it is in NP (verification takes polynomial time) Prove that all problems in NP is reducible to this problem or Prove that a known NPC problem is reducible to this problem If we can prove any given NPC problem can be solve in polynomial time  P=NP For us, before solving a problem, we may check whether it is a NPC problem. If it is, then … Michael Garey and David Johnson: Computers and Intractability - A Guide to the Theory of NP-completeness; Freeman, 1979.