Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Subset-sum Problem

Similar presentations


Presentation on theme: "The Subset-sum Problem"— Presentation transcript:

1 The Subset-sum Problem
Problem statement given the set S = {x1, x2, x3, … xn } of positive integers and t, is there a subset of S that adds up to t as an optimization problem, what subset of S adds up to the greatest total <= t What we will show first we develop an exponential time algorithm to solve the problem exactly we modify this algorithm to give us a fully polynomial time approximation scheme that has a running time that is polynomial in 1/e and n

2 The exponential algorithm
Some preliminaries we use the notation S + x = { s+x : s  S} we have a merge lists algorithm that runs in time proportional to the sum of the lengths of the two lists

3 Why it works Some notation Proof and complexity
Pi is the set of sums of all subsets of values up to xi it can be shown that Proof and complexity by induction on i it can be shown that Li is a sorted list that contains every element of Pi <= t since Li can be as long as 2i, the algorithm, in general, is exponential polynomial time algorithms exist if t is polynomial in |S| or all numbers in S are bounded by a polynomial in |S|

4 Trimming a List To trim by a factor d means a term z can be represented by a smaller term provided it is “close enough” The complexity is (m)

5 A fully-polynomial scheme
The algorithm is similar to our exponential algorithm except we now perform a trim step

6 An example


Download ppt "The Subset-sum Problem"

Similar presentations


Ads by Google