12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

590 Chap. 17 Limits <strong>to</strong> ComputationINDEPENDENT SETInput: A graph G <strong>and</strong> an integer k.Output: YES if there is a subset S of the vertices in G of size k orgreater such that no edge connects any two vertices in S, <strong>and</strong> NO otherwise.Assuming that K-CLIQUE is N P-complete, prove that INDEPENDENTSET is N P-complete.17.11 Define the problem PARTITION as follows:PARTITIONInput: A collection of integers.Output: YES if the collection can be split in<strong>to</strong> two such that the sumof the integers in each partition sums <strong>to</strong> the same amount. NO otherwise.(a) Assuming that PARTITION is N P-complete, prove that the decisionform of BIN PACKING is N P-complete.(b) Assuming that PARTITION is N P-complete, prove that KNAPSACKis N P-complete.17.12 Imagine that you have a problem P that you know is N P-complete. Forthis problem you have two algorithms <strong>to</strong> solve it. For each algorithm, someproblem instances of P run in polynomial time <strong>and</strong> others run in exponentialtime (there are lots of heuristic-based algorithms for real N P-completeproblems with this behavior). You can’t tell beforeh<strong>and</strong> for any given probleminstance whether it will run in polynomial or exponential time on eitheralgorithm. However, you do know that for every problem instance, at leas<strong>to</strong>ne of the two algorithms will solve it in polynomial time.(a) What should you do?(b) What is the running time of your solution?(c) What does it say about the question of P = N P if the conditionsdescribed in this problem existed?17.13 Here is another version of the knapsack problem, which we will call EXACTKNAPSACK. Given a set of items each with given integer size, <strong>and</strong> a knapsackof size integer k, is there a subset of the items which fits exactly withinthe knapsack?Assuming that EXACT KNAPSACK is N P-complete, use a reduction argument<strong>to</strong> prove that KNAPSACK is N P-complete.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!