Advanced Algorithms COMS31900 Approximation algorithms part three - - PowerPoint PPT Presentation

advanced algorithms coms31900 approximation algorithms
SMART_READER_LITE
LIVE PREVIEW

Advanced Algorithms COMS31900 Approximation algorithms part three - - PowerPoint PPT Presentation

Advanced Algorithms COMS31900 Approximation algorithms part three (Fully) Polynomial Time Approximation Schemes Rapha el Clifford Slides by Benjamin Sach Approximation Algorithms Recap An algorithm A is an -approximation algorithm for


slide-1
SLIDE 1

Advanced Algorithms – COMS31900 Approximation algorithms part three (Fully) Polynomial Time Approximation Schemes

Rapha¨ el Clifford Slides by Benjamin Sach

slide-2
SLIDE 2

Approximation Algorithms Recap

An algorithm A is an α-approximation algorithm for problem P if,

  • A runs in polynomial time
  • A always outputs a solution with value s
  • Here P is an optimisation problem with optimal solution of value Opt
  • If P is a maximisation problem, Opt

α

s Opt

within an α factor of Opt

  • If P is a minimisation problem, Opt s α · Opt

We have seen: a 3/2-approximation algorithm for Bin Packing a 2-approximation algorithm for k-centers a 3/2-approximation algorithm for scheduling multiple machines

slide-3
SLIDE 3

The Subset Sum problem

4 4 7 3

2 2 t = 12

slide-4
SLIDE 4

The Subset Sum problem

4 4 7 3

2 2 t = 12

  • Let S be a multi-set of positive integers and t be a positive integer

|S| = m

slide-5
SLIDE 5

The Subset Sum problem

4 4 7 3

2 2 t = 12

  • Let S be a multi-set of positive integers and t be a positive integer

here S = {4, 2, 4, 7, 2, 3} and t = 12

|S| = m

slide-6
SLIDE 6

The Subset Sum problem

4 4 7 3

2 2 t = 12

  • Let S be a multi-set of positive integers and t be a positive integer

here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S′ ⊆ S with size t?

|S| = m

slide-7
SLIDE 7

The Subset Sum problem

4 4 7 3

2 2 t = 12

  • Let S be a multi-set of positive integers and t be a positive integer

here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S′ ⊆ S with size t? the size of S′ is

a∈S′ a

|S| = m

slide-8
SLIDE 8

The Subset Sum problem t = 12

4 4

2

7 3

2

  • Let S be a multi-set of positive integers and t be a positive integer

here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S′ ⊆ S with size t? the size of S′ is

a∈S′ a

|S| = m

slide-9
SLIDE 9

The Subset Sum problem t = 12

7 3

2

4 4

2

  • Let S be a multi-set of positive integers and t be a positive integer

here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S′ ⊆ S with size t? the size of S′ is

a∈S′ a

|S| = m

slide-10
SLIDE 10

The Subset Sum problem t = 12

7 3

2

4 4

2

  • Let S be a multi-set of positive integers and t be a positive integer

here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S′ ⊆ S with size t? the size of S′ is

a∈S′ a

|S| = m

slide-11
SLIDE 11

The Subset Sum problem

4 4 7 3

2 2 t = 12

  • Let S be a multi-set of positive integers and t be a positive integer

here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S′ ⊆ S with size t? the size of S′ is

a∈S′ a

|S| = m

slide-12
SLIDE 12

The Subset Sum problem

4 4 7 3

2 2 t = 12

  • Let S be a multi-set of positive integers and t be a positive integer

here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S′ ⊆ S with size t? Optimisation Problem the size of S′ is

a∈S′ a

Find the size of the largest subset of S which is no larger than t

|S| = m

slide-13
SLIDE 13

The Subset Sum problem

4 4 7 3

2 2 t = 12

  • Let S be a multi-set of positive integers and t be a positive integer

here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S′ ⊆ S with size t? Optimisation Problem the size of S′ is

a∈S′ a

Find the size of the largest subset of S which is no larger than t

|S| = m

slide-14
SLIDE 14

The Subset Sum problem

7

2 2 t = 12

  • Let S be a multi-set of positive integers and t be a positive integer

here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S′ ⊆ S with size t? Optimisation Problem the size of S′ is

a∈S′ a

Find the size of the largest subset of S which is no larger than t

4 4 3

|S| = m

slide-15
SLIDE 15

The Subset Sum problem

7

2 2 t = 12

  • Let S be a multi-set of positive integers and t be a positive integer

here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S′ ⊆ S with size t? Optimisation Problem the size of S′ is

a∈S′ a

Find the size of the largest subset of S which is no larger than t

4 4 3

|S| = m

The answer to the

  • ptimisation problem is ‘11’
slide-16
SLIDE 16

The Subset Sum problem

4 4 7 3

2 2 t = 12

  • Let S be a multi-set of positive integers and t be a positive integer

here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S′ ⊆ S with size t? Optimisation Problem the size of S′ is

a∈S′ a

Find the size of the largest subset of S which is no larger than t

|S| = m

slide-17
SLIDE 17

The Subset Sum problem

4 4 7 3

2 2 t = 12

  • Let S be a multi-set of positive integers and t be a positive integer

here S = {4, 2, 4, 7, 2, 3} and t = 12 Decision Problem Is there a subset, S′ ⊆ S with size t? Optimisation Problem the size of S′ is

a∈S′ a

The optimisation version is NP-hard and the decision version is NP-complete Find the size of the largest subset of S which is no larger than t

|S| = m

slide-18
SLIDE 18

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

4 4 7 3

2 2 S S3 |S| = m

slide-19
SLIDE 19

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

4 4 7 3

2 2 S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

|S| = m

slide-20
SLIDE 20

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

4 4 7 3

2 2 S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

(here t = 12)

|S| = m

slide-21
SLIDE 21

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

(here t = 12)

|S| = m

slide-22
SLIDE 22

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

2

(here t = 12)

|S| = m

slide-23
SLIDE 23

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

4

(here t = 12)

|S| = m

slide-24
SLIDE 24

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

2

4

(here t = 12)

|S| = m

slide-25
SLIDE 25

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

4 4

(here t = 12)

|S| = m

slide-26
SLIDE 26

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

2

4 4

(here t = 12)

|S| = m

slide-27
SLIDE 27

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

2

4 4

(here t = 12)

|S| = m

slide-28
SLIDE 28

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm

2

4 4

(here t = 12)

|S| = m

slide-29
SLIDE 29

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm We compute Li from Li−1:

2

4 4

(here t = 12)

|S| = m

slide-30
SLIDE 30

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm We compute Li from Li−1:

Li = Li−1 ∪ (Li−1 + si)

2

4 4

(here t = 12)

|S| = m

slide-31
SLIDE 31

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm We compute Li from Li−1:

Li = Li−1 ∪ (Li−1 + si)

where (x + si) ∈ (Li−1 + si) iff x ∈ Li−1 and x + si t

2

4 4

(here t = 12)

|S| = m

slide-32
SLIDE 32

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm We compute Li from Li−1:

Li = Li−1 ∪ (Li−1 + si)

where (x + si) ∈ (Li−1 + si) iff x ∈ Li−1 and x + si t (here t = 12)

|S| = m

slide-33
SLIDE 33

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm We compute Li from Li−1:

Li = Li−1 ∪ (Li−1 + si)

where (x + si) ∈ (Li−1 + si) iff x ∈ Li−1 and x + si t

L3 + s4 = L3 + 7 =

{7, 9, 11}

(here t = 12)

|S| = m

slide-34
SLIDE 34

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm We compute Li from Li−1:

Li = Li−1 ∪ (Li−1 + si)

where (x + si) ∈ (Li−1 + si) iff x ∈ Li−1 and x + si t

7

L3 + s4 = L3 + 7 =

{7, 9, 11}

(here t = 12)

|S| = m

s4

slide-35
SLIDE 35

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm We compute Li from Li−1:

Li = Li−1 ∪ (Li−1 + si)

where (x + si) ∈ (Li−1 + si) iff x ∈ Li−1 and x + si t

2

7

L3 + s4 = L3 + 7 =

{7, 9, 11}

(here t = 12)

|S| = m

s4

slide-36
SLIDE 36

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm We compute Li from Li−1:

Li = Li−1 ∪ (Li−1 + si)

where (x + si) ∈ (Li−1 + si) iff x ∈ Li−1 and x + si t

4 7

L3 + s4 = L3 + 7 =

{7, 9, 11}

(here t = 12)

|S| = m

s4

slide-37
SLIDE 37

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm We compute Li from Li−1:

Li = Li−1 ∪ (Li−1 + si)

where (x + si) ∈ (Li−1 + si) iff x ∈ Li−1 and x + si t

2

4 7

L3 + s4 = L3 + 7 =

{7, 9, 11}

(here t = 12)

|S| = m

s4

slide-38
SLIDE 38

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm We compute Li from Li−1:

Li = Li−1 ∪ (Li−1 + si)

where (x + si) ∈ (Li−1 + si) iff x ∈ Li−1 and x + si t

7 4 4

L3 + s4 = L3 + 7 =

{7, 9, 11}

(here t = 12)

|S| = m

s4

slide-39
SLIDE 39

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm We compute Li from Li−1:

Li = Li−1 ∪ (Li−1 + si)

where (x + si) ∈ (Li−1 + si) iff x ∈ Li−1 and x + si t

2

7 4 4

L3 + s4 = L3 + 7 =

{7, 9, 11}

(here t = 12)

|S| = m

s4

slide-40
SLIDE 40

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm We compute Li from Li−1:

Li = Li−1 ∪ (Li−1 + si)

where (x + si) ∈ (Li−1 + si) iff x ∈ Li−1 and x + si t

2

4 4 7

2 L3 + s4 = L3 + 7 =

{7, 9, 11} L4 = {0, 2, 4, 6, 7, 8, 9, 10, 11}

(here t = 12)

|S| = m

s4

slide-41
SLIDE 41

An exact solution

Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}

S S3

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

L3 =

{0, 2, 4, 6, 8, 10}

The largest subset of S (of size at most t) is the largest number in Lm We compute Li from Li−1:

Li = Li−1 ∪ (Li−1 + si)

where (x + si) ∈ (Li−1 + si) iff x ∈ Li−1 and x + si t

2

4 4 7

2 L3 + s4 = L3 + 7 =

{7, 9, 11} L4 = {0, 2, 4, 6, 7, 8, 9, 10, 11}

(here t = 12) We don’t have any duplicates in Li - so |Li| t

|S| = m

s4

slide-42
SLIDE 42

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

|S| = m

slide-43
SLIDE 43

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time

|S| = m

slide-44
SLIDE 44

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time

|S| = m

slide-45
SLIDE 45

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time

|S| = m

slide-46
SLIDE 46

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

|S| = m

slide-47
SLIDE 47

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t

|S| = m

slide-48
SLIDE 48

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t The overall time complexity is therefore O(mt)

|S| = m

slide-49
SLIDE 49

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t The overall time complexity is therefore O(mt) Is this polynomial in n?

|S| = m

slide-50
SLIDE 50

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t The overall time complexity is therefore O(mt) Is this polynomial in n? What even is n?

|S| = m

slide-51
SLIDE 51

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t The overall time complexity is therefore O(mt) Is this polynomial in n? What even is n?

n is the length of the input (measured in words)

|S| = m

slide-52
SLIDE 52

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t The overall time complexity is therefore O(mt) Is this polynomial in n? What even is n?

n is the length of the input (measured in words)

Input

n words

|S| = m

slide-53
SLIDE 53

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t The overall time complexity is therefore O(mt) Is this polynomial in n? What even is n?

n is the length of the input (measured in words)

Input

n words

a w bit word

|S| = m

slide-54
SLIDE 54

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t The overall time complexity is therefore O(mt) Is this polynomial in n? What even is n?

n is the length of the input (measured in words)

Input

n words

a w bit word (conventionally w ∈ Θ(log n))

|S| = m

slide-55
SLIDE 55

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t The overall time complexity is therefore O(mt) Is this polynomial in n? What even is n?

n is the length of the input (measured in words)

Input

n words

|S| = m

slide-56
SLIDE 56

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t The overall time complexity is therefore O(mt) Is this polynomial in n? What even is n?

n is the length of the input (measured in words)

Input

n words

The input to the Subset Sum problem is a list of the elements of S along with t encoded in binary in a total of n words

|S| = m

slide-57
SLIDE 57

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t The overall time complexity is therefore O(mt) Is this polynomial in n? What even is n?

n is the length of the input (measured in words)

Input

n words

The input to the Subset Sum problem is a list of the elements of S along with t encoded in binary in a total of n words

s1 s2 s3 t

|S| = m

slide-58
SLIDE 58

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t The overall time complexity is therefore O(mt) Is this polynomial in n? What even is n?

n is the length of the input (measured in words)

Input

n words

The input to the Subset Sum problem is a list of the elements of S along with t encoded in binary in a total of n words

s1 s2 s3 t

As m n, the time is O(nt)

|S| = m

slide-59
SLIDE 59

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t The overall time complexity is therefore O(mt) Is this polynomial in n? What even is n?

n is the length of the input (measured in words)

Input

n words

The input to the Subset Sum problem is a list of the elements of S along with t encoded in binary in a total of n words

s1 s2 s3 t

As m n, the time is O(nt) . . . but t could be (for example) 2n

|S| = m

slide-60
SLIDE 60

An exact solution

The algorithm

  • Let L0 = {0}
  • For i = 1 . . . m:
  • Compute (Li−1 + si) from Li−1
  • Compute Li = Li−1 ∪ (Li−1 + si)
  • Output the largest number in Lm

O(1) time O(|Li−1|) time O(|Li|) time O(|Lm|) time

Each Li is of length |Li| t The overall time complexity is therefore O(mt) Is this polynomial in n? What even is n?

n is the length of the input (measured in words)

Input

n words

The input to the Subset Sum problem is a list of the elements of S along with t encoded in binary in a total of n words

s1 s2 s3 t

As m n, the time is O(nt) . . . but t could be (for example) 2n

|S| = m

. . . in other words O(n2n) time!

slide-61
SLIDE 61

Pseudo-polynomial time algorithms

We say that an algorithm is pseudo-polynomial time

if it runs in polynomial time when all the numbers are integers nc for some constant c

slide-62
SLIDE 62

Pseudo-polynomial time algorithms

We say that an algorithm is pseudo-polynomial time

if it runs in polynomial time when all the numbers are integers nc for some constant c The algorithm for Subset Sum given takes O(nt) = O(nc+1) time (in this case)

slide-63
SLIDE 63

Pseudo-polynomial time algorithms

We say that an algorithm is pseudo-polynomial time

if it runs in polynomial time when all the numbers are integers nc for some constant c The algorithm for Subset Sum given takes O(nt) = O(nc+1) time (in this case)

So there is a pseudo-polynomial time algorithm for Subset Sum

slide-64
SLIDE 64

Pseudo-polynomial time algorithms

We say that an algorithm is pseudo-polynomial time

if it runs in polynomial time when all the numbers are integers nc for some constant c The algorithm for Subset Sum given takes O(nt) = O(nc+1) time (in this case)

So there is a pseudo-polynomial time algorithm for Subset Sum

A diversion into computational complexity

slide-65
SLIDE 65

Pseudo-polynomial time algorithms

We say that an algorithm is pseudo-polynomial time

if it runs in polynomial time when all the numbers are integers nc for some constant c The algorithm for Subset Sum given takes O(nt) = O(nc+1) time (in this case) We say that an NP-complete problem is weakly NP-complete if there is a pseudo-polynomial time algorithm for it

So there is a pseudo-polynomial time algorithm for Subset Sum

A diversion into computational complexity

slide-66
SLIDE 66

Pseudo-polynomial time algorithms

We say that an algorithm is pseudo-polynomial time

if it runs in polynomial time when all the numbers are integers nc for some constant c The algorithm for Subset Sum given takes O(nt) = O(nc+1) time (in this case) We say that an NP-complete problem is weakly NP-complete if there is a pseudo-polynomial time algorithm for it The decision version of Subset Sum is weakly NP-complete

So there is a pseudo-polynomial time algorithm for Subset Sum

A diversion into computational complexity

slide-67
SLIDE 67

Pseudo-polynomial time algorithms

We say that an algorithm is pseudo-polynomial time

if it runs in polynomial time when all the numbers are integers nc for some constant c The algorithm for Subset Sum given takes O(nt) = O(nc+1) time (in this case) We say that an NP-complete problem is weakly NP-complete if there is a pseudo-polynomial time algorithm for it We say that an NP-complete problem is strongly NP-complete if it remains NP-complete when all the numbers are integers nc The decision version of Subset Sum is weakly NP-complete

So there is a pseudo-polynomial time algorithm for Subset Sum

A diversion into computational complexity

slide-68
SLIDE 68

Pseudo-polynomial time algorithms

We say that an algorithm is pseudo-polynomial time

if it runs in polynomial time when all the numbers are integers nc for some constant c The algorithm for Subset Sum given takes O(nt) = O(nc+1) time (in this case) We say that an NP-complete problem is weakly NP-complete if there is a pseudo-polynomial time algorithm for it We say that an NP-complete problem is strongly NP-complete if it remains NP-complete when all the numbers are integers nc The decision version of Subset Sum is weakly NP-complete The decision version of Bin packing is strongly NP-complete

So there is a pseudo-polynomial time algorithm for Subset Sum

A diversion into computational complexity

slide-69
SLIDE 69

Pseudo-polynomial time algorithms

We say that an algorithm is pseudo-polynomial time

if it runs in polynomial time when all the numbers are integers nc for some constant c The algorithm for Subset Sum given takes O(nt) = O(nc+1) time (in this case) We say that an NP-complete problem is weakly NP-complete if there is a pseudo-polynomial time algorithm for it We say that an NP-complete problem is strongly NP-complete if it remains NP-complete when all the numbers are integers nc The decision version of Subset Sum is weakly NP-complete The decision version of Bin packing is strongly NP-complete

So there is a pseudo-polynomial time algorithm for Subset Sum

A diversion into computational complexity (this only makes sense if you rephrase the problem)

slide-70
SLIDE 70

Pseudo-polynomial time algorithms

We say that an algorithm is pseudo-polynomial time

if it runs in polynomial time when all the numbers are integers nc for some constant c The algorithm for Subset Sum given takes O(nt) = O(nc+1) time (in this case) We say that an NP-complete problem is weakly NP-complete if there is a pseudo-polynomial time algorithm for it We say that an NP-complete problem is strongly NP-complete if it remains NP-complete when all the numbers are integers nc The decision version of Subset Sum is weakly NP-complete The decision version of Bin packing is strongly NP-complete

So there is a pseudo-polynomial time algorithm for Subset Sum

A diversion into computational complexity item sizes are integers in [nc]

4

bins have size

t ∈ [nc]

(this only makes sense if you rephrase the problem)

slide-71
SLIDE 71

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P

slide-72
SLIDE 72

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P

  • If we had a PTAS for Subset Sum we could:
slide-73
SLIDE 73

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P

  • If we had a PTAS for Subset Sum we could:

Let ǫ = 0.1 so that A0.1 runs in polynomial time and

  • utputs a subset of size at least Opt

1.1 > 0.9 · Opt

slide-74
SLIDE 74

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P

  • If we had a PTAS for Subset Sum we could:

Let ǫ = 0.01 so that A0.01 also runs in polynomial time and

  • utputs a subset of size at least Opt

1.01 > 0.99 · Opt

Let ǫ = 0.1 so that A0.1 runs in polynomial time and

  • utputs a subset of size at least Opt

1.1 > 0.9 · Opt

slide-75
SLIDE 75

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P

  • If we had a PTAS for Subset Sum we could:

Let ǫ = 0.01 so that A0.01 also runs in polynomial time and

  • utputs a subset of size at least Opt

1.01 > 0.99 · Opt

Let ǫ = 0.1 so that A0.1 runs in polynomial time and

  • utputs a subset of size at least Opt

1.1 > 0.9 · Opt

Let ǫ = 0.001 so that A0.001 also runs in polynomial time and

  • utputs a subset of size at least Opt

1.001 > 0.999 · Opt

slide-76
SLIDE 76

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P

  • If we had a PTAS for Subset Sum we could:

Let ǫ = 0.1 so that A0.1 runs in polynomial time and

  • utputs a subset of size at least Opt

1.1 > 0.9 · Opt

slide-77
SLIDE 77

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P

  • If we had a PTAS for Subset Sum we could:

Let ǫ = 0.1 so that A0.1 runs in polynomial time and

  • utputs a subset of size at least Opt

1.1 > 0.9 · Opt

A PTAS does not have to have a time complexity which is polynomial in 1/ǫ

slide-78
SLIDE 78

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P

  • If we had a PTAS for Subset Sum we could:

Let ǫ = 0.1 so that A0.1 runs in polynomial time and

  • utputs a subset of size at least Opt

1.1 > 0.9 · Opt

A PTAS does not have to have a time complexity which is polynomial in 1/ǫ

Aǫ can have a time complexity of O(n

c ǫ ) for example

slide-79
SLIDE 79

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P

  • If we had a PTAS for Subset Sum we could:

Let ǫ = 0.1 so that A0.1 runs in polynomial time and

  • utputs a subset of size at least Opt

1.1 > 0.9 · Opt

A PTAS does not have to have a time complexity which is polynomial in 1/ǫ

Aǫ can have a time complexity of O(n

c ǫ ) for example

O(n10c) vs. O(n100c) vs. O(n1000c) in our example

ǫ = 0.1 ǫ = 0.01 ǫ = 0.001

slide-80
SLIDE 80

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P

  • If we had a PTAS for Subset Sum we could:

Let ǫ = 0.1 so that A0.1 runs in polynomial time and

  • utputs a subset of size at least Opt

1.1 > 0.9 · Opt

A PTAS does not have to have a time complexity which is polynomial in 1/ǫ

slide-81
SLIDE 81

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P

  • If we had a PTAS for Subset Sum we could:

Let ǫ = 0.1 so that A0.1 runs in polynomial time and

  • utputs a subset of size at least Opt

1.1 > 0.9 · Opt

A PTAS does not have to have a time complexity which is polynomial in 1/ǫ A fully PTAS (FPTAS) has a time complexity which is polynomial in 1/ǫ (as well as polynomial in n)

slide-82
SLIDE 82

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P

  • If we had a PTAS for Subset Sum we could:

Let ǫ = 0.1 so that A0.1 runs in polynomial time and

  • utputs a subset of size at least Opt

1.1 > 0.9 · Opt

A PTAS does not have to have a time complexity which is polynomial in 1/ǫ A fully PTAS (FPTAS) has a time complexity which is polynomial in 1/ǫ (as well as polynomial in n) i.e. the time complexity is O((n/ǫ)c) for some constant c

slide-83
SLIDE 83

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P

  • If we had a PTAS for Subset Sum we could:

Let ǫ = 0.1 so that A0.1 runs in polynomial time and

  • utputs a subset of size at least Opt

1.1 > 0.9 · Opt

A PTAS does not have to have a time complexity which is polynomial in 1/ǫ A fully PTAS (FPTAS) has a time complexity which is polynomial in 1/ǫ (as well as polynomial in n) i.e. the time complexity is O((n/ǫ)c) for some constant c In our example O((10n)c) = O((100n)c) = O((1000n)c) = O(nc)

ǫ = 0.1 ǫ = 0.01 ǫ = 0.001

slide-84
SLIDE 84

A PTAS for Subset Sum

Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t (where Si = {s1, s2, . . . , si} - the first i numbers in the input)

3 S S4

L4 = {0, 2, 4, 6, 7, 8, 9, 10, 11} 2

4

2 2

4 7

(here t = 12)

4

2

4 7 4 4 7

2

4 4

2

7 4

slide-85
SLIDE 85

A PTAS for Subset Sum

The exact algorithm for Subset Sum was slow (in general) because each list of possible subset sizes Li could become very large Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t (where Si = {s1, s2, . . . , si} - the first i numbers in the input)

3 S S4

L4 = {0, 2, 4, 6, 7, 8, 9, 10, 11} 2

4

2 2

4 7

(here t = 12)

4

2

4 7 4 4 7

2

4 4

2

7 4

slide-86
SLIDE 86

A PTAS for Subset Sum

Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t Key Idea Construct a trimmed version of Li (denoted L′

i ⊆ Li) so that

(where Si = {s1, s2, . . . , si} - the first i numbers in the input)

slide-87
SLIDE 87

A PTAS for Subset Sum

Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t Key Idea Construct a trimmed version of Li (denoted L′

i ⊆ Li) so that

(where Si = {s1, s2, . . . , si} - the first i numbers in the input)

L′

i is a subset of Li (i.e. L′ i ⊆ Li)

slide-88
SLIDE 88

A PTAS for Subset Sum

Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t Key Idea Construct a trimmed version of Li (denoted L′

i ⊆ Li) so that

The length of L′

i is polynomial in the input length (i.e. |L′ i| nc for some c)

(where Si = {s1, s2, . . . , si} - the first i numbers in the input)

L′

i is a subset of Li (i.e. L′ i ⊆ Li)

slide-89
SLIDE 89

A PTAS for Subset Sum

Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t Key Idea Construct a trimmed version of Li (denoted L′

i ⊆ Li) so that

The length of L′

i is polynomial in the input length (i.e. |L′ i| nc for some c)

For every y ∈ Li, there is a z ∈ L′

i which is almost as big

(where Si = {s1, s2, . . . , si} - the first i numbers in the input)

L′

i is a subset of Li (i.e. L′ i ⊆ Li)

slide-90
SLIDE 90

A PTAS for Subset Sum

Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t Key Idea Construct a trimmed version of Li (denoted L′

i ⊆ Li) so that

The length of L′

i is polynomial in the input length (i.e. |L′ i| nc for some c)

For every y ∈ Li, there is a z ∈ L′

i which is almost as big

(where Si = {s1, s2, . . . , si} - the first i numbers in the input)

L′

i is a subset of Li (i.e. L′ i ⊆ Li)

Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in L′

i iff

where prev is the previous

Li[j] > (1 + δ) · prev

entry we included in L′

i

slide-91
SLIDE 91

A PTAS for Subset Sum

Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t Key Idea Construct a trimmed version of Li (denoted L′

i ⊆ Li) so that

The length of L′

i is polynomial in the input length (i.e. |L′ i| nc for some c)

For every y ∈ Li, there is a z ∈ L′

i which is almost as big

(where Si = {s1, s2, . . . , si} - the first i numbers in the input)

L′

i is a subset of Li (i.e. L′ i ⊆ Li)

Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in L′

i iff

where prev is the previous

L4 = {0, 2, 4, 6, 7, 8, 9, 10, 11} 2

4

2

4 7 4 4 7

2

4 4

2

7 4 Li[j] > (1 + δ) · prev

entry we included in L′

i

slide-92
SLIDE 92

A PTAS for Subset Sum

Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t Key Idea Construct a trimmed version of Li (denoted L′

i ⊆ Li) so that

The length of L′

i is polynomial in the input length (i.e. |L′ i| nc for some c)

For every y ∈ Li, there is a z ∈ L′

i which is almost as big

for δ = 1. . . L′

4 = {0, 2, 6}

(where Si = {s1, s2, . . . , si} - the first i numbers in the input)

L′

i is a subset of Li (i.e. L′ i ⊆ Li)

Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in L′

i iff

where prev is the previous

L4 = {0, 2, 4, 6, 7, 8, 9, 10, 11} 2

4

2

4 7 4 4 7

2

4 4

2

7 4 Li[j] > (1 + δ) · prev

entry we included in L′

i

slide-93
SLIDE 93

A PTAS for Subset Sum

Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t Key Idea Construct a trimmed version of Li (denoted L′

i ⊆ Li) so that

The length of L′

i is polynomial in the input length (i.e. |L′ i| nc for some c)

For every y ∈ Li, there is a z ∈ L′

i which is almost as big

for δ = 1. . . L′

4 = {0, 2, 6}

(where Si = {s1, s2, . . . , si} - the first i numbers in the input)

L′

i is a subset of Li (i.e. L′ i ⊆ Li)

Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in L′

i iff

where prev is the previous

L4 = {0, 2, 4, 6, 7, 8, 9, 10, 11} 2

4

2

4 7 4 4 7

2

4 4

2

7 4 Li[j] > (1 + δ) · prev

entry we included in L′

i

L′

4 is a small subset of L4 and for any y ∈ L4,

there is an z ∈ L′

4 with z y/2

slide-94
SLIDE 94

A PTAS for Subset Sum

Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t Key Idea Construct a trimmed version of Li (denoted L′

i ⊆ Li) so that

The length of L′

i is polynomial in the input length (i.e. |L′ i| nc for some c)

For every y ∈ Li, there is a z ∈ L′

i which is almost as big

(where Si = {s1, s2, . . . , si} - the first i numbers in the input)

L′

i is a subset of Li (i.e. L′ i ⊆ Li)

Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in L′

i iff

where prev is the previous

Li[j] > (1 + δ) · prev

entry we included in L′

i

slide-95
SLIDE 95

A PTAS for Subset Sum

Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t Key Idea Construct a trimmed version of Li (denoted L′

i ⊆ Li) so that

The length of L′

i is polynomial in the input length (i.e. |L′ i| nc for some c)

For every y ∈ Li, there is a z ∈ L′

i which is almost as big

(where Si = {s1, s2, . . . , si} - the first i numbers in the input)

L′

i is a subset of Li (i.e. L′ i ⊆ Li)

Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in L′

i iff

where prev is the previous

Li[j] > (1 + δ) · prev

entry we included in L′

i

Unfortunately, this hasn’t really achieved anything. . .

slide-96
SLIDE 96

A PTAS for Subset Sum

Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t Key Idea Construct a trimmed version of Li (denoted L′

i ⊆ Li) so that

The length of L′

i is polynomial in the input length (i.e. |L′ i| nc for some c)

For every y ∈ Li, there is a z ∈ L′

i which is almost as big

(where Si = {s1, s2, . . . , si} - the first i numbers in the input)

L′

i is a subset of Li (i.e. L′ i ⊆ Li)

Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in L′

i iff

where prev is the previous

Li[j] > (1 + δ) · prev

entry we included in L′

i

Unfortunately, this hasn’t really achieved anything. . . we don’t have time to compute Li and then trim it

(because Li might be very big)

slide-97
SLIDE 97

A PTAS for Subset Sum

Recall that Li is the set of sizes of all S′ ⊆ Si which are not larger than t Key Idea Construct a trimmed version of Li (denoted L′

i ⊆ Li) so that

The length of L′

i is polynomial in the input length (i.e. |L′ i| nc for some c)

For every y ∈ Li, there is a z ∈ L′

i which is almost as big

(where Si = {s1, s2, . . . , si} - the first i numbers in the input)

L′

i is a subset of Li (i.e. L′ i ⊆ Li)

Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in L′

i iff

where prev is the previous

Li[j] > (1 + δ) · prev

entry we included in L′

i

Unfortunately, this hasn’t really achieved anything. . . we don’t have time to compute Li and then trim it Instead, we will trim as we go along. . .

(because Li might be very big)

slide-98
SLIDE 98

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

  • Let L′

i = Trim(U, δ)

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

|S| = m

slide-99
SLIDE 99

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

  • Let L′

i = Trim(U, δ)

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

Trim(U, δ): Include U[j] in L′

i iff U[j] > (1 + δ) · prev

where prev is the previous thing we included in L′

i

|S| = m

slide-100
SLIDE 100

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

  • Let L′

i = Trim(U, δ)

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

|S| = m

slide-101
SLIDE 101

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

  • Let L′

i = Trim(U, δ)

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

2 2

4 L′

i−1 =

si = 3 |S| = m

slide-102
SLIDE 102

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

  • Let L′

i = Trim(U, δ)

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

2 2

4 L′

i−1 =

si = 3

2

(L′

i−1 + si) =

3 3 |S| = m

slide-103
SLIDE 103

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

  • Let L′

i = Trim(U, δ)

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

2 2

4 L′

i−1 =

si = 3

2

(L′

i−1 + si) =

U = L′

i−1 ∪ (L′ i−1 + si) = 2 2

4

2

3 4 3 3 3

2

|S| = m

slide-104
SLIDE 104

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

  • Let L′

i = Trim(U, δ)

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

2 2

4 L′

i−1 =

si = 3

2

(L′

i−1 + si) =

U = L′

i−1 ∪ (L′ i−1 + si) = 2 2

4

2

3

= L′

i = Trim(U, δ)

2

(with δ = 1)

4 3 3 3

2 2

3 |S| = m

slide-105
SLIDE 105

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

  • Let L′

i = Trim(U, δ)

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

2 2

4 L′

i−1 =

si = 3

2

(L′

i−1 + si) =

U = L′

i−1 ∪ (L′ i−1 + si) = 2 2

4

2

3

= L′

i = Trim(U, δ)

2

(with δ = 1)

4 3 3 3

keep each thing if it is more than (1 + δ) times as big as the last thing you kept

2 2

3 |S| = m

slide-106
SLIDE 106

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

  • Let L′

i = Trim(U, δ)

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

|S| = m

slide-107
SLIDE 107

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

  • Let L′

i = Trim(U, δ)

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

|S| = m

slide-108
SLIDE 108

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i−1|) time

  • Let L′

i = Trim(U, δ)

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

|S| = m

slide-109
SLIDE 109

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i−1|) time

O(|L′

i|) time

  • Let L′

i = Trim(U, δ)

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

|S| = m

slide-110
SLIDE 110

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i−1|) time

O(|L′

i|) time

  • Let L′

i = Trim(U, δ)

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

Trim(U, δ): Include U[j] in L′

i iff U[j] > (1 + δ) · prev

where prev is the previous thing we included in L′

i

|S| = m

slide-111
SLIDE 111

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i−1|) time

O(|L′

i|) time

  • Let L′

i = Trim(U, δ)

O(|L′

m|) time

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

Trim(U, δ): Include U[j] in L′

i iff U[j] > (1 + δ) · prev

where prev is the previous thing we included in L′

i

|S| = m

slide-112
SLIDE 112

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i−1|) time

O(|L′

i|) time

  • Let L′

i = Trim(U, δ)

O(|L′

m|) time

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

|S| = m

slide-113
SLIDE 113

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i−1|) time

O(|L′

i|) time

This algorithm throws away some possible subsets,

  • Let L′

i = Trim(U, δ)

O(|L′

m|) time

but it always outputs a valid subset (but probably not the largest one) Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

|S| = m

slide-114
SLIDE 114

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i−1|) time

O(|L′

i|) time

This algorithm throws away some possible subsets, Two questions remain. . .

  • Let L′

i = Trim(U, δ)

O(|L′

m|) time

but it always outputs a valid subset (but probably not the largest one) Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

|S| = m

slide-115
SLIDE 115

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i−1|) time

O(|L′

i|) time

This algorithm throws away some possible subsets, Two questions remain. . .

  • Let L′

i = Trim(U, δ)

O(|L′

m|) time

but it always outputs a valid subset (but probably not the largest one)

How big is |L′

i|?

How good is the solution given?

Let Li be the set of sizes of all S′ ⊆ Si which are not larger than t

  • L′

i is the trimmed version of Li

|S| = m

slide-116
SLIDE 116

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y |S| = m

slide-117
SLIDE 117

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

For any entry in the original set (Li) . . . there is one in the trimmed set (L′

i) . . .

  • f a ‘similar’ size (δ is very small)

|S| = m

slide-118
SLIDE 118

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y |S| = m

slide-119
SLIDE 119

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction)

|S| = m

slide-120
SLIDE 120

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

|S| = m

slide-121
SLIDE 121

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1)

|S| = m

slide-122
SLIDE 122

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1

|S| = m

slide-123
SLIDE 123

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1 if y ∈ Li−1 then there is a x ∈ L′

i−1 with

y (1+δ)(i−1) x y

|S| = m

slide-124
SLIDE 124

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1 if y ∈ Li−1 then there is a x ∈ L′

i−1 with

y (1+δ)(i−1) x y

by the inductive hypothesis

|S| = m

slide-125
SLIDE 125

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1 if y ∈ Li−1 then there is a x ∈ L′

i−1 with

y (1+δ)(i−1) x y

|S| = m

slide-126
SLIDE 126

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1 if y ∈ Li−1 then there is a x ∈ L′

i−1 with

y (1+δ)(i−1) x y

By the definition of Trim there is some z ∈ L′

i with z x z · (1 + δ)

|S| = m

slide-127
SLIDE 127

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1 if y ∈ Li−1 then there is a x ∈ L′

i−1 with

y (1+δ)(i−1) x y

By the definition of Trim there is some z ∈ L′

i with z x z · (1 + δ)

So we have that z x y and z

x 1+δ y (1+δ)i

|S| = m

slide-128
SLIDE 128

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1 if y ∈ Li−1 then there is a x ∈ L′

i−1 with

y (1+δ)(i−1) x y

By the definition of Trim there is some z ∈ L′

i with z x z · (1 + δ)

So we have that z x y and z

x 1+δ y (1+δ)i

|S| = m

slide-129
SLIDE 129

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1 if y ∈ Li−1 then there is a x ∈ L′

i−1 with

y (1+δ)(i−1) x y

By the definition of Trim there is some z ∈ L′

i with z x z · (1 + δ)

So we have that z x y and z

x 1+δ y (1+δ)i

|S| = m

slide-130
SLIDE 130

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1 if y ∈ Li−1 then there is a x ∈ L′

i−1 with

y (1+δ)(i−1) x y

By the definition of Trim there is some z ∈ L′

i with z x z · (1 + δ)

So we have that z x y and z

x 1+δ y (1+δ)i

|S| = m

slide-131
SLIDE 131

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1 if y ∈ Li−1 then there is a x ∈ L′

i−1 with

y (1+δ)(i−1) x y

By the definition of Trim there is some z ∈ L′

i with z x z · (1 + δ)

So we have that z x y and z

x 1+δ y (1+δ)i

|S| = m

slide-132
SLIDE 132

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1 if y ∈ Li−1 then there is a x ∈ L′

i−1 with

y (1+δ)(i−1) x y

By the definition of Trim there is some z ∈ L′

i with z x z · (1 + δ)

So we have that z x y and z

x 1+δ y (1+δ)i

|S| = m

slide-133
SLIDE 133

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1 if y ∈ Li−1 then there is a x ∈ L′

i−1 with

y (1+δ)(i−1) x y

By the definition of Trim there is some z ∈ L′

i with z x z · (1 + δ)

So we have that z x y and z

x 1+δ y (1+δ)i

I.e. that there is an z ∈ L′

i with

y (1+δ)i z y as required |S| = m

slide-134
SLIDE 134

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1 if y ∈ Li−1 then there is a x ∈ L′

i−1 with

y (1+δ)(i−1) x y

By the definition of Trim there is some z ∈ L′

i with z x z · (1 + δ)

So we have that z x y and z

x 1+δ y (1+δ)i

The case that (y − si) ∈ Li−1 is almost identical I.e. that there is an z ∈ L′

i with

y (1+δ)i z y as required |S| = m

slide-135
SLIDE 135

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

Proof (by induction) Base Case: L0 = L′

0 = {0}

Inductive step: Assume that the lemma holds for (i − 1) As y ∈ Li we have that either y ∈ Li−1 or (y − si) ∈ Li−1 if y ∈ Li−1 then there is a x ∈ L′

i−1 with

y (1+δ)(i−1) x y

By the definition of Trim there is some z ∈ L′

i with z x z · (1 + δ)

So we have that z x y and z

x 1+δ y (1+δ)i

The case that (y − si) ∈ Li−1 is almost identical (we omit it for brevity) I.e. that there is an z ∈ L′

i with

y (1+δ)i z y as required |S| = m

slide-136
SLIDE 136

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y |S| = m

slide-137
SLIDE 137

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

By setting i = m and δ = ǫ/2m we have that, For any y ∈ Lm there is a z ∈ L′

m with

y (1 +

ǫ 2m )m z y

|S| = m

slide-138
SLIDE 138

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

By setting i = m and δ = ǫ/2m we have that, For any y ∈ Lm there is a z ∈ L′

m with

y (1 +

ǫ 2m )m z y

Further, Opt ∈ Lm meaning there is a z ∈ L′

m with

Opt

  • 1 +

ǫ 2m

m z Opt |S| = m

slide-139
SLIDE 139

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

By setting i = m and δ = ǫ/2m we have that, For any y ∈ Lm there is a z ∈ L′

m with

y (1 +

ǫ 2m )m z y

Further, Opt ∈ Lm meaning there is a z ∈ L′

m with

Opt

  • 1 +

ǫ 2m

m z Opt

Recall that the output of the algorithm is the largest number in L′

  • m. . .

|S| = m

slide-140
SLIDE 140

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

By setting i = m and δ = ǫ/2m we have that, For any y ∈ Lm there is a z ∈ L′

m with

y (1 +

ǫ 2m )m z y

Further, Opt ∈ Lm meaning there is a z ∈ L′

m with

Opt

  • 1 +

ǫ 2m

m z Opt

We only need to show that

  • 1 +

ǫ 2m

m 1 + ǫ . . .

Recall that the output of the algorithm is the largest number in L′

  • m. . .

|S| = m

slide-141
SLIDE 141

Li vs. L′

i

Lemma For any y ∈ Li there is an z ∈ L′

i with

y (1+δ)i z y

By setting i = m and δ = ǫ/2m we have that, For any y ∈ Lm there is a z ∈ L′

m with

y (1 +

ǫ 2m )m z y

Further, Opt ∈ Lm meaning there is a z ∈ L′

m with

Opt

  • 1 +

ǫ 2m

m z Opt

We only need to show that

  • 1 +

ǫ 2m

m 1 + ǫ . . .

Recall that the output of the algorithm is the largest number in L′

  • m. . .

|S| = m

VS

Opt 1 + ǫ z Opt

slide-142
SLIDE 142

Li vs. L′

i

We need to show that

  • 1 +

ǫ 2m

m 1 + ǫ (for 0 < ǫ 1)

|S| = m

slide-143
SLIDE 143

Li vs. L′

i

We need to show that

  • 1 +

ǫ 2m

m 1 + ǫ (for 0 < ǫ 1)

  • 1 + ǫ

2m m eǫ/2 1+ǫ 2+ ǫ 2 2 1+ǫ

|S| = m

slide-144
SLIDE 144

Li vs. L′

i

We need to show that

  • 1 +

ǫ 2m

m 1 + ǫ (for 0 < ǫ 1)

  • 1 + ǫ

2m m eǫ/2 1+ǫ 2+ ǫ 2 2 1+ǫ ex = ∞

i=0 xi i! 1 + x + x2

This follows from the following facts:

ex (1 + x

m )m for all x, m > 0

|S| = m

slide-145
SLIDE 145

Li vs. L′

i

We need to show that

  • 1 +

ǫ 2m

m 1 + ǫ (for 0 < ǫ 1)

  • 1 + ǫ

2m m eǫ/2 1+ǫ 2+ ǫ 2 2 1+ǫ

So the output of the algorithm is some z where,

|S| = m

slide-146
SLIDE 146

Li vs. L′

i

We need to show that

  • 1 +

ǫ 2m

m 1 + ǫ (for 0 < ǫ 1)

  • 1 + ǫ

2m m eǫ/2 1+ǫ 2+ ǫ 2 2 1+ǫ

So the output of the algorithm is some z where,

Opt 1 + ǫ Opt

  • 1 +

ǫ 2m

m z Opt |S| = m

slide-147
SLIDE 147

Li vs. L′

i

We need to show that

  • 1 +

ǫ 2m

m 1 + ǫ (for 0 < ǫ 1)

  • 1 + ǫ

2m m eǫ/2 1+ǫ 2+ ǫ 2 2 1+ǫ

So the output of the algorithm is some z where,

Opt 1 + ǫ z Opt |S| = m

slide-148
SLIDE 148

Li vs. L′

i

We need to show that

  • 1 +

ǫ 2m

m 1 + ǫ (for 0 < ǫ 1)

  • 1 + ǫ

2m m eǫ/2 1+ǫ 2+ ǫ 2 2 1+ǫ

So the output of the algorithm is some z where,

But how long does it take to run?

Opt 1 + ǫ z Opt |S| = m

slide-149
SLIDE 149

How big is L′ i?

The time complexity depends on |L′

i|. . .

|S| = m

slide-150
SLIDE 150

How big is L′ i?

The time complexity depends on |L′

i|. . .

By the definition of Trim we have that, any two successive elements, z, z′ of L′

i have

z′ z 1 + δ = 1 + ǫ 2m

|S| = m

slide-151
SLIDE 151

How big is L′ i?

The time complexity depends on |L′

i|. . .

By the definition of Trim we have that, any two successive elements, z, z′ of L′

i have

z′ z 1 + δ = 1 + ǫ 2m

Further, all elements are no greater than t

|S| = m

slide-152
SLIDE 152

How big is L′ i?

The time complexity depends on |L′

i|. . .

By the definition of Trim we have that, any two successive elements, z, z′ of L′

i have

z′ z 1 + δ = 1 + ǫ 2m

Further, all elements are no greater than t So L′

i contains at most O(log(1+δ) t) elements

|S| = m

slide-153
SLIDE 153

How big is L′ i?

The time complexity depends on |L′

i|. . .

By the definition of Trim we have that, any two successive elements, z, z′ of L′

i have

z′ z 1 + δ = 1 + ǫ 2m

Further, all elements are no greater than t So L′

i contains at most O(log(1+δ) t) elements

log(1+δ) t = ln t ln(1 + (ǫ/2m)) 2m(1 + (ǫ/2m)) ln t ǫ = O m log t ǫ

  • |S| = m
slide-154
SLIDE 154

How big is L′ i?

The time complexity depends on |L′

i|. . .

By the definition of Trim we have that, any two successive elements, z, z′ of L′

i have

z′ z 1 + δ = 1 + ǫ 2m

Further, all elements are no greater than t So L′

i contains at most O(log(1+δ) t) elements

log(1+δ) t = ln t ln(1 + (ǫ/2m)) 2m(1 + (ǫ/2m)) ln t ǫ = O m log t ǫ

  • ln(1 + x) >

x x+1

(here x = ǫ/2m)

another fact:

|S| = m

slide-155
SLIDE 155

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i|) time

O(|L′

i|) time

  • Let L′

i = Trim(U, δ)

O(|L′

m|) time

|S| = m

slide-156
SLIDE 156

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i|) time

O(|L′

i|) time

As |L′

i| = O(m log t/ǫ), the algorithm runs in

  • Let L′

i = Trim(U, δ)

O(|L′

m|) time

O(m2 log t/ǫ) = O(n3 log n/ǫ) time

|S| = m

slide-157
SLIDE 157

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i|) time

O(|L′

i|) time

As |L′

i| = O(m log t/ǫ), the algorithm runs in

  • Let L′

i = Trim(U, δ)

O(|L′

m|) time

O(m2 log t/ǫ) = O(n3 log n/ǫ) time

|S| = m m n log t = O(n log n)

Recall that n is the length of the input (measured in words)

slide-158
SLIDE 158

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i|) time

O(|L′

i|) time

As |L′

i| = O(m log t/ǫ), the algorithm runs in

  • Let L′

i = Trim(U, δ)

O(|L′

m|) time

O(m2 log t/ǫ) = O(n3 log n/ǫ) time

|S| = m

slide-159
SLIDE 159

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i|) time

O(|L′

i|) time

As |L′

i| = O(m log t/ǫ), the algorithm runs in

The output z is such that

  • Let L′

i = Trim(U, δ)

O(|L′

m|) time

O(m2 log t/ǫ) = O(n3 log n/ǫ) time Opt 1 + ǫ z Opt

|S| = m

slide-160
SLIDE 160

A PTAS for Subset Sum

The algorithm

  • Let L′

0 = {0}, δ = ǫ/(2m)

  • For i = 1 . . . m:
  • Compute (L′

i−1 + si) from L′ i−1

  • Compute U = L′

i−1 ∪ (L′ i−1 + si)

  • Output the largest number in L′

m

O(|L′

i−1|) time

O(|L′

i|) time

O(|L′

i|) time

As |L′

i| = O(m log t/ǫ), the algorithm runs in

The output z is such that

  • Let L′

i = Trim(U, δ)

O(|L′

m|) time

O(m2 log t/ǫ) = O(n3 log n/ǫ) time Opt 1 + ǫ z Opt

So this is in fact an FPTAS for Subset Sum

|S| = m

slide-161
SLIDE 161

Polynomial time approximation schemes

A Polynomial Time Approximation Scheme (PTAS) for problem P is a family of algorithms: For any constant ǫ > 0 there is an algorithm in the family, Aǫ such that Aǫ is a (1 + ǫ)-approximation algorithm for P We have seen an FPTAS for Subset Sum A PTAS does not have to have a time complexity which is polynomial in 1/ǫ A fully PTAS (FPTAS) has a time complexity which is polynomial in 1/ǫ (as well as polynomial in n) i.e. the time complexity is O((n/ǫ)c) for some constant c e.g. the time complexity could be O(n

c ǫ ) (for example)

which runs in O(n3 log n/ǫ) time The output z is such that

Opt 1 + ǫ z Opt