SlideShare a Scribd company logo
Advanced Algorithms – COMS31900
Approximation algorithms part three
(Fully) Polynomial Time Approximation Schemes
Benjamin Sach
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
The Subset Sum problem
4 4
7
322
t = 12
The Subset Sum problem
4 4
7
322
t = 12
• Let S be a multi-set of positive integers and t be a positive integer
|S| = m
The Subset Sum problem
4 4
7
322
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
The Subset Sum problem
4 4
7
322
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
The Subset Sum problem
4 4
7
322
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
The Subset Sum problem
t = 12
4
4
2
7
32
• 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
The Subset Sum problem
t = 12
7
3
2
4 42
• 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
The Subset Sum problem
t = 12
7
3
2
4 42
• 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
The Subset Sum problem
4 4
7
322
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
The Subset Sum problem
4 4
7
322
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
The Subset Sum problem
4 4
7
322
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
The Subset Sum problem
7
22
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 Subset Sum problem
7
22
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
optimisation problem is ‘11’
The Subset Sum problem
4 4
7
322
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
The Subset Sum problem
4 4
7
322
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
An exact solution
Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}
4 4
7
322
S
S3
|S| = m
An exact solution
Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}
4 4
7
322
S
S3
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
|S| = m
An exact solution
Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si}
4 4
7
322
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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!
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
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)
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
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
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
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
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
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
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)
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)
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
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:
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
outputs a subset of size at least
Opt
1.1 > 0.9 · Opt
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
outputs a subset of size at least
Opt
1.01 > 0.99 · Opt
Let = 0.1 so that A0.1 runs in polynomial time and
outputs a subset of size at least
Opt
1.1 > 0.9 · Opt
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
outputs a subset of size at least
Opt
1.01 > 0.99 · Opt
Let = 0.1 so that A0.1 runs in polynomial time and
outputs 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
outputs a subset of size at least
Opt
1.001 > 0.999 · Opt
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
outputs a subset of size at least
Opt
1.1 > 0.9 · Opt
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
outputs 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/
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
outputs 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
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
outputs 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
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
outputs 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/
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
outputs 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)
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
outputs 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
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
outputs 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
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 24
7
(here t = 12)
4
2
4
7
4
4
7
2
4
4
2
7
4
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 24
7
(here t = 12)
4
2
4
7
4
4
7
2
4
4
2
7
4
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 Li ⊆ Li) so that
(where Si = {s1, s2, . . . , si} - the first i numbers in the input)
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 Li ⊆ Li) so that
(where Si = {s1, s2, . . . , si} - the first i numbers in the input)
Li is a subset of Li (i.e. Li ⊆ Li)
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 Li ⊆ Li) so that
The length of Li is polynomial in the input length (i.e. |Li| nc for some c)
(where Si = {s1, s2, . . . , si} - the first i numbers in the input)
Li is a subset of Li (i.e. Li ⊆ Li)
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 Li ⊆ Li) so that
The length of Li is polynomial in the input length (i.e. |Li| nc for some c)
For every y ∈ Li, there is a z ∈ Li which is almost as big
(where Si = {s1, s2, . . . , si} - the first i numbers in the input)
Li is a subset of Li (i.e. Li ⊆ Li)
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 Li ⊆ Li) so that
The length of Li is polynomial in the input length (i.e. |Li| nc for some c)
For every y ∈ Li, there is a z ∈ Li which is almost as big
(where Si = {s1, s2, . . . , si} - the first i numbers in the input)
Li is a subset of Li (i.e. Li ⊆ Li)
Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li iff
where prev is the previous
Li[j] > (1 + δ) · prev
entry we included in Li
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 Li ⊆ Li) so that
The length of Li is polynomial in the input length (i.e. |Li| nc for some c)
For every y ∈ Li, there is a z ∈ Li which is almost as big
(where Si = {s1, s2, . . . , si} - the first i numbers in the input)
Li is a subset of Li (i.e. Li ⊆ Li)
Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li 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 Li
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 Li ⊆ Li) so that
The length of Li is polynomial in the input length (i.e. |Li| nc for some c)
For every y ∈ Li, there is a z ∈ Li which is almost as big
for δ = 1. . . L4 = {0, 2, 6}
(where Si = {s1, s2, . . . , si} - the first i numbers in the input)
Li is a subset of Li (i.e. Li ⊆ Li)
Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li 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 Li
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 Li ⊆ Li) so that
The length of Li is polynomial in the input length (i.e. |Li| nc for some c)
For every y ∈ Li, there is a z ∈ Li which is almost as big
for δ = 1. . . L4 = {0, 2, 6}
(where Si = {s1, s2, . . . , si} - the first i numbers in the input)
Li is a subset of Li (i.e. Li ⊆ Li)
Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li 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 Li
L4 is a small subset of L4 and for any y ∈ L4,
there is an z ∈ L4 with z y/2
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 Li ⊆ Li) so that
The length of Li is polynomial in the input length (i.e. |Li| nc for some c)
For every y ∈ Li, there is a z ∈ Li which is almost as big
(where Si = {s1, s2, . . . , si} - the first i numbers in the input)
Li is a subset of Li (i.e. Li ⊆ Li)
Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li iff
where prev is the previous
Li[j] > (1 + δ) · prev
entry we included in Li
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 Li ⊆ Li) so that
The length of Li is polynomial in the input length (i.e. |Li| nc for some c)
For every y ∈ Li, there is a z ∈ Li which is almost as big
(where Si = {s1, s2, . . . , si} - the first i numbers in the input)
Li is a subset of Li (i.e. Li ⊆ Li)
Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li iff
where prev is the previous
Li[j] > (1 + δ) · prev
entry we included in Li
Unfortunately, this hasn’t really achieved anything. . .
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 Li ⊆ Li) so that
The length of Li is polynomial in the input length (i.e. |Li| nc for some c)
For every y ∈ Li, there is a z ∈ Li which is almost as big
(where Si = {s1, s2, . . . , si} - the first i numbers in the input)
Li is a subset of Li (i.e. Li ⊆ Li)
Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li iff
where prev is the previous
Li[j] > (1 + δ) · prev
entry we included in Li
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)
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 Li ⊆ Li) so that
The length of Li is polynomial in the input length (i.e. |Li| nc for some c)
For every y ∈ Li, there is a z ∈ Li which is almost as big
(where Si = {s1, s2, . . . , si} - the first i numbers in the input)
Li is a subset of Li (i.e. Li ⊆ Li)
Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li iff
where prev is the previous
Li[j] > (1 + δ) · prev
entry we included in Li
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)
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
◦ Let Li = Trim(U, δ)
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
◦ Let Li = Trim(U, δ)
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
Trim(U, δ): Include U[j] in Li iff U[j] > (1 + δ) · prev
where prev is the previous thing we included in Li
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
◦ Let Li = Trim(U, δ)
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
◦ Let Li = Trim(U, δ)
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
2
2
4
Li−1 = si = 3
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
◦ Let Li = Trim(U, δ)
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
2
2
4
Li−1 = si = 3
2
(Li−1 + si) =
3
3
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
◦ Let Li = Trim(U, δ)
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
2
2
4
Li−1 = si = 3
2
(Li−1 + si) =
U = Li−1 ∪ (Li−1 + si) =
2
2
42
3 4
3
3
3
2
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
◦ Let Li = Trim(U, δ)
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
2
2
4
Li−1 = si = 3
2
(Li−1 + si) =
U = Li−1 ∪ (Li−1 + si) =
2
2
42
3
= Li = Trim(U, δ)
2
(with δ = 1)
4
3
3
3
2
2
3
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
◦ Let Li = Trim(U, δ)
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
2
2
4
Li−1 = si = 3
2
(Li−1 + si) =
U = Li−1 ∪ (Li−1 + si) =
2
2
42
3
= Li = 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
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
◦ Let Li = Trim(U, δ)
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
◦ Let Li = Trim(U, δ)
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li−1|) time
◦ Let Li = Trim(U, δ)
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li−1|) time
O(|Li|) time
◦ Let Li = Trim(U, δ)
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li−1|) time
O(|Li|) time
◦ Let Li = Trim(U, δ)
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
Trim(U, δ): Include U[j] in Li iff U[j] > (1 + δ) · prev
where prev is the previous thing we included in Li
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li−1|) time
O(|Li|) time
◦ Let Li = Trim(U, δ)
O(|Lm|) time
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
Trim(U, δ): Include U[j] in Li iff U[j] > (1 + δ) · prev
where prev is the previous thing we included in Li
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li−1|) time
O(|Li|) time
◦ Let Li = Trim(U, δ)
O(|Lm|) time
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li−1|) time
O(|Li|) time
This algorithm throws away some possible subsets,
◦ Let Li = Trim(U, δ)
O(|Lm|) 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
- Li is the trimmed version of Li
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li−1|) time
O(|Li|) time
This algorithm throws away some possible subsets,
Two questions remain. . .
◦ Let Li = Trim(U, δ)
O(|Lm|) 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
- Li is the trimmed version of Li
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li−1|) time
O(|Li|) time
This algorithm throws away some possible subsets,
Two questions remain. . .
◦ Let Li = Trim(U, δ)
O(|Lm|) time
but it always outputs a valid subset (but probably not the largest one)
How big is |Li|? How good is the solution given?
Let Li be the set of sizes of all S ⊆ Si which are not larger than t
- Li is the trimmed version of Li
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
For any entry in the original set (Li) . . .
there is one in the trimmed set (Li) . . .
of a ‘similar’ size (δ is very small)
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {0}
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {0}
Inductive step: Assume that the lemma holds for (i − 1)
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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 ∈ Li−1 with
y
(1+δ)(i−1) x y
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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 ∈ Li−1 with
y
(1+δ)(i−1) x y
by the inductive hypothesis
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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 ∈ Li−1 with
y
(1+δ)(i−1) x y
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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 ∈ Li−1 with
y
(1+δ)(i−1) x y
By the definition of Trim there is some z ∈ Li with z x z · (1 + δ)
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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 ∈ Li−1 with
y
(1+δ)(i−1) x y
By the definition of Trim there is some z ∈ Li with z x z · (1 + δ)
So we have that z x y and z x
1+δ
y
(1+δ)i
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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 ∈ Li−1 with
y
(1+δ)(i−1) x y
By the definition of Trim there is some z ∈ Li with z x z · (1 + δ)
So we have that z x y and z x
1+δ
y
(1+δ)i
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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 ∈ Li−1 with
y
(1+δ)(i−1) x y
By the definition of Trim there is some z ∈ Li with z x z · (1 + δ)
So we have that z x y and z x
1+δ
y
(1+δ)i
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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 ∈ Li−1 with
y
(1+δ)(i−1) x y
By the definition of Trim there is some z ∈ Li with z x z · (1 + δ)
So we have that z x y and z x
1+δ
y
(1+δ)i
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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 ∈ Li−1 with
y
(1+δ)(i−1) x y
By the definition of Trim there is some z ∈ Li with z x z · (1 + δ)
So we have that z x y and z x
1+δ
y
(1+δ)i
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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 ∈ Li−1 with
y
(1+δ)(i−1) x y
By the definition of Trim there is some z ∈ Li with z x z · (1 + δ)
So we have that z x y and z x
1+δ
y
(1+δ)i
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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 ∈ Li−1 with
y
(1+δ)(i−1) x y
By the definition of Trim there is some z ∈ Li 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 ∈ Li with
y
(1+δ)i z y as required
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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 ∈ Li−1 with
y
(1+δ)(i−1) x y
By the definition of Trim there is some z ∈ Li 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 ∈ Li with
y
(1+δ)i z y as required
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
Proof (by induction)
Base Case: L0 = L0 = {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 ∈ Li−1 with
y
(1+δ)(i−1) x y
By the definition of Trim there is some z ∈ Li 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 ∈ Li with
y
(1+δ)i z y as required
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
By setting i = m and δ = /2m we have that,
For any y ∈ Lm there is a z ∈ Lm with
y
(1 + 2m )m
z y
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
By setting i = m and δ = /2m we have that,
For any y ∈ Lm there is a z ∈ Lm with
y
(1 + 2m )m
z y
Further, Opt ∈ Lm meaning there is a z ∈ Lm with
Opt
1 + 2m
m z Opt
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
By setting i = m and δ = /2m we have that,
For any y ∈ Lm there is a z ∈ Lm with
y
(1 + 2m )m
z y
Further, Opt ∈ Lm meaning there is a z ∈ Lm with
Opt
1 + 2m
m z Opt
Recall that the output of the algorithm is the largest number in Lm. . .
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
By setting i = m and δ = /2m we have that,
For any y ∈ Lm there is a z ∈ Lm with
y
(1 + 2m )m
z y
Further, Opt ∈ Lm meaning there is a z ∈ Lm 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 Lm. . .
|S| = m
Li vs. Li
Lemma For any y ∈ Li there is an z ∈ Li with
y
(1+δ)i z y
By setting i = m and δ = /2m we have that,
For any y ∈ Lm there is a z ∈ Lm with
y
(1 + 2m )m
z y
Further, Opt ∈ Lm meaning there is a z ∈ Lm 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 Lm. . .
|S| = m
VS
Opt
1 +
z Opt
Li vs. Li
We need to show that 1 + 2m
m
1 + (for 0 < 1)
|S| = m
Li vs. Li
We need to show that 1 + 2m
m
1 + (for 0 < 1)
1 +
2m
m
e /2
1+
2
+
2
2
1+
|S| = m
Li vs. Li
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
Li vs. Li
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
Li vs. Li
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
Li vs. Li
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
Li vs. Li
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
How big is Li?
The time complexity depends on |Li|. . .
|S| = m
How big is Li?
The time complexity depends on |Li|. . .
By the definition of Trim we have that,
any two successive elements, z, z of Li have
z
z 1 + δ = 1 + 2m
|S| = m
How big is Li?
The time complexity depends on |Li|. . .
By the definition of Trim we have that,
any two successive elements, z, z of Li have
z
z 1 + δ = 1 + 2m
Further, all elements are no greater than t
|S| = m
How big is Li?
The time complexity depends on |Li|. . .
By the definition of Trim we have that,
any two successive elements, z, z of Li have
z
z 1 + δ = 1 + 2m
Further, all elements are no greater than t
So Li contains at most O(log(1+δ) t) elements
|S| = m
How big is Li?
The time complexity depends on |Li|. . .
By the definition of Trim we have that,
any two successive elements, z, z of Li have
z
z 1 + δ = 1 + 2m
Further, all elements are no greater than t
So Li 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
How big is Li?
The time complexity depends on |Li|. . .
By the definition of Trim we have that,
any two successive elements, z, z of Li have
z
z 1 + δ = 1 + 2m
Further, all elements are no greater than t
So Li 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
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li|) time
O(|Li|) time
◦ Let Li = Trim(U, δ)
O(|Lm|) time
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li|) time
O(|Li|) time
As |Li| = O(m log t/ ), the algorithm runs in
◦ Let Li = Trim(U, δ)
O(|Lm|) time
O(m2 log t/ ) = O(n3 log n/ ) time
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li|) time
O(|Li|) time
As |Li| = O(m log t/ ), the algorithm runs in
◦ Let Li = Trim(U, δ)
O(|Lm|) 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)
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li|) time
O(|Li|) time
As |Li| = O(m log t/ ), the algorithm runs in
◦ Let Li = Trim(U, δ)
O(|Lm|) time
O(m2 log t/ ) = O(n3 log n/ ) time
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li|) time
O(|Li|) time
As |Li| = O(m log t/ ), the algorithm runs in
The output z is such that
◦ Let Li = Trim(U, δ)
O(|Lm|) time
O(m2 log t/ ) = O(n3 log n/ ) time
Opt
1 +
z Opt
|S| = m
A PTAS for Subset Sum
The algorithm
◦ Let L0 = {0}, δ = /(2m)
◦ For i = 1 . . . m:
◦ Compute (Li−1 + si) from Li−1
◦ Compute U = Li−1 ∪ (Li−1 + si)
◦ Output the largest number in Lm
O(|Li−1|) time
O(|Li|) time
O(|Li|) time
As |Li| = O(m log t/ ), the algorithm runs in
The output z is such that
◦ Let Li = Trim(U, δ)
O(|Lm|) 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
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
Ad

More Related Content

What's hot (18)

Arithmetic sequences and series[1]
Arithmetic sequences and series[1]Arithmetic sequences and series[1]
Arithmetic sequences and series[1]
indu psthakur
 
Algebra
AlgebraAlgebra
Algebra
Christian Bation
 
Sequence and series
Sequence and series Sequence and series
Sequence and series
Sukhtej Sethi
 
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Aladdinew
 
Group Theory and Its Application: Beamer Presentation (PPT)
Group Theory and Its Application:   Beamer Presentation (PPT)Group Theory and Its Application:   Beamer Presentation (PPT)
Group Theory and Its Application: Beamer Presentation (PPT)
SIRAJAHMAD36
 
Sequence and series
Sequence and seriesSequence and series
Sequence and series
Denmar Marasigan
 
Sequences and series
Sequences and seriesSequences and series
Sequences and series
Leo Crisologo
 
Sequences and series
Sequences and seriesSequences and series
Sequences and series
anithaselvakumar271
 
Discrete mathematics Ch1 sets Theory_Dr.Khaled.Bakro د. خالد بكرو
Discrete mathematics Ch1 sets Theory_Dr.Khaled.Bakro د. خالد بكروDiscrete mathematics Ch1 sets Theory_Dr.Khaled.Bakro د. خالد بكرو
Discrete mathematics Ch1 sets Theory_Dr.Khaled.Bakro د. خالد بكرو
Dr. Khaled Bakro
 
Set theory
Set theorySet theory
Set theory
Gaditek
 
Discrete Math Chapter 2: Basic Structures: Sets, Functions, Sequences, Sums, ...
Discrete Math Chapter 2: Basic Structures: Sets, Functions, Sequences, Sums, ...Discrete Math Chapter 2: Basic Structures: Sets, Functions, Sequences, Sums, ...
Discrete Math Chapter 2: Basic Structures: Sets, Functions, Sequences, Sums, ...
Amr Rashed
 
Maths project work - Arithmetic Sequences
Maths project work - Arithmetic SequencesMaths project work - Arithmetic Sequences
Maths project work - Arithmetic Sequences
S.L.B.S Engineering College
 
Geometric Progressions
Geometric ProgressionsGeometric Progressions
Geometric Progressions
itutor
 
Set theory
Set theorySet theory
Set theory
Shiwani Gupta
 
BCA_Semester-II-Discrete Mathematics_unit-i Group theory
BCA_Semester-II-Discrete Mathematics_unit-i Group theoryBCA_Semester-II-Discrete Mathematics_unit-i Group theory
BCA_Semester-II-Discrete Mathematics_unit-i Group theory
Rai University
 
Abstract Algebra Cheat Sheet
Abstract Algebra Cheat SheetAbstract Algebra Cheat Sheet
Abstract Algebra Cheat Sheet
Moe Han
 
Discrete mathematic
Discrete mathematicDiscrete mathematic
Discrete mathematic
Naralaswapna
 
Arithmetic Sequence and Series
Arithmetic Sequence and SeriesArithmetic Sequence and Series
Arithmetic Sequence and Series
itutor
 
Arithmetic sequences and series[1]
Arithmetic sequences and series[1]Arithmetic sequences and series[1]
Arithmetic sequences and series[1]
indu psthakur
 
Sequence and series
Sequence and series Sequence and series
Sequence and series
Sukhtej Sethi
 
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Solutions Manual for An Introduction To Abstract Algebra With Notes To The Fu...
Aladdinew
 
Group Theory and Its Application: Beamer Presentation (PPT)
Group Theory and Its Application:   Beamer Presentation (PPT)Group Theory and Its Application:   Beamer Presentation (PPT)
Group Theory and Its Application: Beamer Presentation (PPT)
SIRAJAHMAD36
 
Sequences and series
Sequences and seriesSequences and series
Sequences and series
Leo Crisologo
 
Discrete mathematics Ch1 sets Theory_Dr.Khaled.Bakro د. خالد بكرو
Discrete mathematics Ch1 sets Theory_Dr.Khaled.Bakro د. خالد بكروDiscrete mathematics Ch1 sets Theory_Dr.Khaled.Bakro د. خالد بكرو
Discrete mathematics Ch1 sets Theory_Dr.Khaled.Bakro د. خالد بكرو
Dr. Khaled Bakro
 
Set theory
Set theorySet theory
Set theory
Gaditek
 
Discrete Math Chapter 2: Basic Structures: Sets, Functions, Sequences, Sums, ...
Discrete Math Chapter 2: Basic Structures: Sets, Functions, Sequences, Sums, ...Discrete Math Chapter 2: Basic Structures: Sets, Functions, Sequences, Sums, ...
Discrete Math Chapter 2: Basic Structures: Sets, Functions, Sequences, Sums, ...
Amr Rashed
 
Geometric Progressions
Geometric ProgressionsGeometric Progressions
Geometric Progressions
itutor
 
BCA_Semester-II-Discrete Mathematics_unit-i Group theory
BCA_Semester-II-Discrete Mathematics_unit-i Group theoryBCA_Semester-II-Discrete Mathematics_unit-i Group theory
BCA_Semester-II-Discrete Mathematics_unit-i Group theory
Rai University
 
Abstract Algebra Cheat Sheet
Abstract Algebra Cheat SheetAbstract Algebra Cheat Sheet
Abstract Algebra Cheat Sheet
Moe Han
 
Discrete mathematic
Discrete mathematicDiscrete mathematic
Discrete mathematic
Naralaswapna
 
Arithmetic Sequence and Series
Arithmetic Sequence and SeriesArithmetic Sequence and Series
Arithmetic Sequence and Series
itutor
 

Similar to Approximation Algorithms Part Three: (F)PTAS (20)

Sequence function
Sequence functionSequence function
Sequence function
jennytuazon01630
 
file_5.pptx
file_5.pptxfile_5.pptx
file_5.pptx
MdMuhaiminurRahmanRu
 
Cardinality
CardinalityCardinality
Cardinality
gizemk
 
20MA101 MATHEMATICS I COURSE MATERIAL R2020
20MA101 MATHEMATICS I COURSE MATERIAL R202020MA101 MATHEMATICS I COURSE MATERIAL R2020
20MA101 MATHEMATICS I COURSE MATERIAL R2020
DBalraj1
 
11.2 Arithmetic Sequences and Series
11.2 Arithmetic Sequences and Series11.2 Arithmetic Sequences and Series
11.2 Arithmetic Sequences and Series
smiller5
 
number theory
number theorynumber theory
number theory
klawdet
 
1.2 simplifying expressions and order of operations
1.2 simplifying expressions and order of operations1.2 simplifying expressions and order of operations
1.2 simplifying expressions and order of operations
Huron School District
 
Section 8.3.ppt
Section 8.3.pptSection 8.3.ppt
Section 8.3.ppt
ssuser149b32
 
9.4 Series and Their Notations
9.4 Series and Their Notations9.4 Series and Their Notations
9.4 Series and Their Notations
smiller5
 
Arithmetic progression
Arithmetic progressionArithmetic progression
Arithmetic progression
lashika madaan
 
Section 11-2 Algebra 2
Section 11-2 Algebra 2Section 11-2 Algebra 2
Section 11-2 Algebra 2
Jimbo Lamb
 
Sequence and series
Sequence and seriesSequence and series
Sequence and series
KAZEMBETVOnline
 
ARITHMETIC-MEANS-AND-SERIES.pptx
ARITHMETIC-MEANS-AND-SERIES.pptxARITHMETIC-MEANS-AND-SERIES.pptx
ARITHMETIC-MEANS-AND-SERIES.pptx
RyanAintsimp1
 
11.3 Geometric Sequences and Series
11.3 Geometric Sequences and Series11.3 Geometric Sequences and Series
11.3 Geometric Sequences and Series
smiller5
 
Patterns & Arithmetic Sequences.pptx
Patterns & Arithmetic Sequences.pptxPatterns & Arithmetic Sequences.pptx
Patterns & Arithmetic Sequences.pptx
DeanAriolaSan
 
AP&GP.pptx
AP&GP.pptxAP&GP.pptx
AP&GP.pptx
NANDHINIS900805
 
Class-X Arithmetic Progression PPTfhjiong
Class-X Arithmetic Progression PPTfhjiongClass-X Arithmetic Progression PPTfhjiong
Class-X Arithmetic Progression PPTfhjiong
niranjanedu1337
 
Arithmetic Sequence and Arithmetic Series
Arithmetic Sequence and Arithmetic SeriesArithmetic Sequence and Arithmetic Series
Arithmetic Sequence and Arithmetic Series
Joey Fontanilla Valdriz
 
Worded Problems on age, clock, mixture.pptx
Worded Problems on age, clock, mixture.pptxWorded Problems on age, clock, mixture.pptx
Worded Problems on age, clock, mixture.pptx
ChristineTorrepenida1
 
13 3 arithmetic and geometric series and their sums
13 3 arithmetic and geometric series and their sums13 3 arithmetic and geometric series and their sums
13 3 arithmetic and geometric series and their sums
hisema01
 
Cardinality
CardinalityCardinality
Cardinality
gizemk
 
20MA101 MATHEMATICS I COURSE MATERIAL R2020
20MA101 MATHEMATICS I COURSE MATERIAL R202020MA101 MATHEMATICS I COURSE MATERIAL R2020
20MA101 MATHEMATICS I COURSE MATERIAL R2020
DBalraj1
 
11.2 Arithmetic Sequences and Series
11.2 Arithmetic Sequences and Series11.2 Arithmetic Sequences and Series
11.2 Arithmetic Sequences and Series
smiller5
 
number theory
number theorynumber theory
number theory
klawdet
 
1.2 simplifying expressions and order of operations
1.2 simplifying expressions and order of operations1.2 simplifying expressions and order of operations
1.2 simplifying expressions and order of operations
Huron School District
 
9.4 Series and Their Notations
9.4 Series and Their Notations9.4 Series and Their Notations
9.4 Series and Their Notations
smiller5
 
Arithmetic progression
Arithmetic progressionArithmetic progression
Arithmetic progression
lashika madaan
 
Section 11-2 Algebra 2
Section 11-2 Algebra 2Section 11-2 Algebra 2
Section 11-2 Algebra 2
Jimbo Lamb
 
ARITHMETIC-MEANS-AND-SERIES.pptx
ARITHMETIC-MEANS-AND-SERIES.pptxARITHMETIC-MEANS-AND-SERIES.pptx
ARITHMETIC-MEANS-AND-SERIES.pptx
RyanAintsimp1
 
11.3 Geometric Sequences and Series
11.3 Geometric Sequences and Series11.3 Geometric Sequences and Series
11.3 Geometric Sequences and Series
smiller5
 
Patterns & Arithmetic Sequences.pptx
Patterns & Arithmetic Sequences.pptxPatterns & Arithmetic Sequences.pptx
Patterns & Arithmetic Sequences.pptx
DeanAriolaSan
 
Class-X Arithmetic Progression PPTfhjiong
Class-X Arithmetic Progression PPTfhjiongClass-X Arithmetic Progression PPTfhjiong
Class-X Arithmetic Progression PPTfhjiong
niranjanedu1337
 
Arithmetic Sequence and Arithmetic Series
Arithmetic Sequence and Arithmetic SeriesArithmetic Sequence and Arithmetic Series
Arithmetic Sequence and Arithmetic Series
Joey Fontanilla Valdriz
 
Worded Problems on age, clock, mixture.pptx
Worded Problems on age, clock, mixture.pptxWorded Problems on age, clock, mixture.pptx
Worded Problems on age, clock, mixture.pptx
ChristineTorrepenida1
 
13 3 arithmetic and geometric series and their sums
13 3 arithmetic and geometric series and their sums13 3 arithmetic and geometric series and their sums
13 3 arithmetic and geometric series and their sums
hisema01
 
Ad

More from Benjamin Sach (20)

Approximation Algorithms Part Two: More Constant factor approximations
Approximation Algorithms Part Two: More Constant factor approximationsApproximation Algorithms Part Two: More Constant factor approximations
Approximation Algorithms Part Two: More Constant factor approximations
Benjamin Sach
 
Approximation Algorithms Part One: Constant factor approximations
Approximation Algorithms Part One: Constant factor approximationsApproximation Algorithms Part One: Constant factor approximations
Approximation Algorithms Part One: Constant factor approximations
Benjamin Sach
 
van Emde Boas trees
van Emde Boas treesvan Emde Boas trees
van Emde Boas trees
Benjamin Sach
 
Orthogonal Range Searching
Orthogonal Range SearchingOrthogonal Range Searching
Orthogonal Range Searching
Benjamin Sach
 
Pattern Matching Part Two: k-mismatches
Pattern Matching Part Two: k-mismatchesPattern Matching Part Two: k-mismatches
Pattern Matching Part Two: k-mismatches
Benjamin Sach
 
Pattern Matching Part Three: Hamming Distance
Pattern Matching Part Three: Hamming DistancePattern Matching Part Three: Hamming Distance
Pattern Matching Part Three: Hamming Distance
Benjamin Sach
 
Lowest Common Ancestor
Lowest Common AncestorLowest Common Ancestor
Lowest Common Ancestor
Benjamin Sach
 
Range Minimum Queries
Range Minimum QueriesRange Minimum Queries
Range Minimum Queries
Benjamin Sach
 
Pattern Matching Part Two: Suffix Arrays
Pattern Matching Part Two: Suffix ArraysPattern Matching Part Two: Suffix Arrays
Pattern Matching Part Two: Suffix Arrays
Benjamin Sach
 
Pattern Matching Part One: Suffix Trees
Pattern Matching Part One: Suffix TreesPattern Matching Part One: Suffix Trees
Pattern Matching Part One: Suffix Trees
Benjamin Sach
 
Hashing Part Two: Cuckoo Hashing
Hashing Part Two: Cuckoo HashingHashing Part Two: Cuckoo Hashing
Hashing Part Two: Cuckoo Hashing
Benjamin Sach
 
Hashing Part Two: Static Perfect Hashing
Hashing Part Two: Static Perfect HashingHashing Part Two: Static Perfect Hashing
Hashing Part Two: Static Perfect Hashing
Benjamin Sach
 
Hashing Part One
Hashing Part OneHashing Part One
Hashing Part One
Benjamin Sach
 
Probability Recap
Probability RecapProbability Recap
Probability Recap
Benjamin Sach
 
Bloom Filters
Bloom FiltersBloom Filters
Bloom Filters
Benjamin Sach
 
Dynamic Programming
Dynamic ProgrammingDynamic Programming
Dynamic Programming
Benjamin Sach
 
Minimum Spanning Trees (via Disjoint Sets)
Minimum Spanning Trees (via Disjoint Sets)Minimum Spanning Trees (via Disjoint Sets)
Minimum Spanning Trees (via Disjoint Sets)
Benjamin Sach
 
Shortest Paths Part 1: Priority Queues and Dijkstra's Algorithm
Shortest Paths Part 1: Priority Queues and Dijkstra's AlgorithmShortest Paths Part 1: Priority Queues and Dijkstra's Algorithm
Shortest Paths Part 1: Priority Queues and Dijkstra's Algorithm
Benjamin Sach
 
Depth First Search and Breadth First Search
Depth First Search and Breadth First SearchDepth First Search and Breadth First Search
Depth First Search and Breadth First Search
Benjamin Sach
 
Shortest Paths Part 2: Negative Weights and All-pairs
Shortest Paths Part 2: Negative Weights and All-pairsShortest Paths Part 2: Negative Weights and All-pairs
Shortest Paths Part 2: Negative Weights and All-pairs
Benjamin Sach
 
Approximation Algorithms Part Two: More Constant factor approximations
Approximation Algorithms Part Two: More Constant factor approximationsApproximation Algorithms Part Two: More Constant factor approximations
Approximation Algorithms Part Two: More Constant factor approximations
Benjamin Sach
 
Approximation Algorithms Part One: Constant factor approximations
Approximation Algorithms Part One: Constant factor approximationsApproximation Algorithms Part One: Constant factor approximations
Approximation Algorithms Part One: Constant factor approximations
Benjamin Sach
 
Orthogonal Range Searching
Orthogonal Range SearchingOrthogonal Range Searching
Orthogonal Range Searching
Benjamin Sach
 
Pattern Matching Part Two: k-mismatches
Pattern Matching Part Two: k-mismatchesPattern Matching Part Two: k-mismatches
Pattern Matching Part Two: k-mismatches
Benjamin Sach
 
Pattern Matching Part Three: Hamming Distance
Pattern Matching Part Three: Hamming DistancePattern Matching Part Three: Hamming Distance
Pattern Matching Part Three: Hamming Distance
Benjamin Sach
 
Lowest Common Ancestor
Lowest Common AncestorLowest Common Ancestor
Lowest Common Ancestor
Benjamin Sach
 
Range Minimum Queries
Range Minimum QueriesRange Minimum Queries
Range Minimum Queries
Benjamin Sach
 
Pattern Matching Part Two: Suffix Arrays
Pattern Matching Part Two: Suffix ArraysPattern Matching Part Two: Suffix Arrays
Pattern Matching Part Two: Suffix Arrays
Benjamin Sach
 
Pattern Matching Part One: Suffix Trees
Pattern Matching Part One: Suffix TreesPattern Matching Part One: Suffix Trees
Pattern Matching Part One: Suffix Trees
Benjamin Sach
 
Hashing Part Two: Cuckoo Hashing
Hashing Part Two: Cuckoo HashingHashing Part Two: Cuckoo Hashing
Hashing Part Two: Cuckoo Hashing
Benjamin Sach
 
Hashing Part Two: Static Perfect Hashing
Hashing Part Two: Static Perfect HashingHashing Part Two: Static Perfect Hashing
Hashing Part Two: Static Perfect Hashing
Benjamin Sach
 
Minimum Spanning Trees (via Disjoint Sets)
Minimum Spanning Trees (via Disjoint Sets)Minimum Spanning Trees (via Disjoint Sets)
Minimum Spanning Trees (via Disjoint Sets)
Benjamin Sach
 
Shortest Paths Part 1: Priority Queues and Dijkstra's Algorithm
Shortest Paths Part 1: Priority Queues and Dijkstra's AlgorithmShortest Paths Part 1: Priority Queues and Dijkstra's Algorithm
Shortest Paths Part 1: Priority Queues and Dijkstra's Algorithm
Benjamin Sach
 
Depth First Search and Breadth First Search
Depth First Search and Breadth First SearchDepth First Search and Breadth First Search
Depth First Search and Breadth First Search
Benjamin Sach
 
Shortest Paths Part 2: Negative Weights and All-pairs
Shortest Paths Part 2: Negative Weights and All-pairsShortest Paths Part 2: Negative Weights and All-pairs
Shortest Paths Part 2: Negative Weights and All-pairs
Benjamin Sach
 
Ad

Recently uploaded (20)

INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
INDIA QUIZ FOR SCHOOLS | THE QUIZ CLUB OF PSGCAS | AUGUST 2024
Quiz Club of PSG College of Arts & Science
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
Cyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top QuestionsCyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top Questions
SONU HEETSON
 
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptxUnit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Mayuri Chavan
 
Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-14-2025 .pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-14-2025  .pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-14-2025  .pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-14-2025 .pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
Conditions for Boltzmann Law – Biophysics Lecture Slide
Conditions for Boltzmann Law – Biophysics Lecture SlideConditions for Boltzmann Law – Biophysics Lecture Slide
Conditions for Boltzmann Law – Biophysics Lecture Slide
PKLI-Institute of Nursing and Allied Health Sciences Lahore , Pakistan.
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
The History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.pptThe History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.ppt
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Rebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter worldRebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter world
Ned Potter
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
materi 3D Augmented Reality dengan assemblr
materi 3D Augmented Reality dengan assemblrmateri 3D Augmented Reality dengan assemblr
materi 3D Augmented Reality dengan assemblr
fatikhatunnajikhah1
 
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdfIPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
Quiz Club of PSG College of Arts & Science
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
Cyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top QuestionsCyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top Questions
SONU HEETSON
 
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptxUnit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Mayuri Chavan
 
Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
How to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale OrderHow to Change Sequence Number in Odoo 18 Sale Order
How to Change Sequence Number in Odoo 18 Sale Order
Celine George
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Rebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter worldRebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter world
Ned Potter
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
UPSA JUDGEMENT.pdfCopyright Infringement: High Court Rules against UPSA: A Wa...
businessweekghana
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
materi 3D Augmented Reality dengan assemblr
materi 3D Augmented Reality dengan assemblrmateri 3D Augmented Reality dengan assemblr
materi 3D Augmented Reality dengan assemblr
fatikhatunnajikhah1
 
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 

Approximation Algorithms Part Three: (F)PTAS

  • 1. Advanced Algorithms – COMS31900 Approximation algorithms part three (Fully) Polynomial Time Approximation Schemes Benjamin Sach
  • 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
  • 3. The Subset Sum problem 4 4 7 322 t = 12
  • 4. The Subset Sum problem 4 4 7 322 t = 12 • Let S be a multi-set of positive integers and t be a positive integer |S| = m
  • 5. The Subset Sum problem 4 4 7 322 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
  • 6. The Subset Sum problem 4 4 7 322 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
  • 7. The Subset Sum problem 4 4 7 322 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
  • 8. The Subset Sum problem t = 12 4 4 2 7 32 • 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
  • 9. The Subset Sum problem t = 12 7 3 2 4 42 • 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
  • 10. The Subset Sum problem t = 12 7 3 2 4 42 • 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
  • 11. The Subset Sum problem 4 4 7 322 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
  • 12. The Subset Sum problem 4 4 7 322 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
  • 13. The Subset Sum problem 4 4 7 322 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
  • 14. The Subset Sum problem 7 22 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
  • 15. The Subset Sum problem 7 22 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 optimisation problem is ‘11’
  • 16. The Subset Sum problem 4 4 7 322 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
  • 17. The Subset Sum problem 4 4 7 322 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
  • 18. An exact solution Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si} 4 4 7 322 S S3 |S| = m
  • 19. An exact solution Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si} 4 4 7 322 S S3 Let Li be the set of sizes of all S ⊆ Si which are not larger than t |S| = m
  • 20. An exact solution Let S = {s1, s2, s3 . . . sm} be the set of items and Si = {s1, s2, . . . , si} 4 4 7 322 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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!
  • 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
  • 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)
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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)
  • 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)
  • 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
  • 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:
  • 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 outputs a subset of size at least Opt 1.1 > 0.9 · Opt
  • 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 outputs a subset of size at least Opt 1.01 > 0.99 · Opt Let = 0.1 so that A0.1 runs in polynomial time and outputs a subset of size at least Opt 1.1 > 0.9 · Opt
  • 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 outputs a subset of size at least Opt 1.01 > 0.99 · Opt Let = 0.1 so that A0.1 runs in polynomial time and outputs 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 outputs a subset of size at least Opt 1.001 > 0.999 · Opt
  • 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 outputs a subset of size at least Opt 1.1 > 0.9 · Opt
  • 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 outputs 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/
  • 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 outputs 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
  • 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 outputs 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
  • 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 outputs 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/
  • 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 outputs 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)
  • 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 outputs 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
  • 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 outputs 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
  • 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 24 7 (here t = 12) 4 2 4 7 4 4 7 2 4 4 2 7 4
  • 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 24 7 (here t = 12) 4 2 4 7 4 4 7 2 4 4 2 7 4
  • 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 Li ⊆ Li) so that (where Si = {s1, s2, . . . , si} - the first i numbers in the input)
  • 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 Li ⊆ Li) so that (where Si = {s1, s2, . . . , si} - the first i numbers in the input) Li is a subset of Li (i.e. Li ⊆ Li)
  • 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 Li ⊆ Li) so that The length of Li is polynomial in the input length (i.e. |Li| nc for some c) (where Si = {s1, s2, . . . , si} - the first i numbers in the input) Li is a subset of Li (i.e. Li ⊆ Li)
  • 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 Li ⊆ Li) so that The length of Li is polynomial in the input length (i.e. |Li| nc for some c) For every y ∈ Li, there is a z ∈ Li which is almost as big (where Si = {s1, s2, . . . , si} - the first i numbers in the input) Li is a subset of Li (i.e. Li ⊆ Li)
  • 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 Li ⊆ Li) so that The length of Li is polynomial in the input length (i.e. |Li| nc for some c) For every y ∈ Li, there is a z ∈ Li which is almost as big (where Si = {s1, s2, . . . , si} - the first i numbers in the input) Li is a subset of Li (i.e. Li ⊆ Li) Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li iff where prev is the previous Li[j] > (1 + δ) · prev entry we included in Li
  • 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 Li ⊆ Li) so that The length of Li is polynomial in the input length (i.e. |Li| nc for some c) For every y ∈ Li, there is a z ∈ Li which is almost as big (where Si = {s1, s2, . . . , si} - the first i numbers in the input) Li is a subset of Li (i.e. Li ⊆ Li) Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li 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 Li
  • 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 Li ⊆ Li) so that The length of Li is polynomial in the input length (i.e. |Li| nc for some c) For every y ∈ Li, there is a z ∈ Li which is almost as big for δ = 1. . . L4 = {0, 2, 6} (where Si = {s1, s2, . . . , si} - the first i numbers in the input) Li is a subset of Li (i.e. Li ⊆ Li) Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li 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 Li
  • 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 Li ⊆ Li) so that The length of Li is polynomial in the input length (i.e. |Li| nc for some c) For every y ∈ Li, there is a z ∈ Li which is almost as big for δ = 1. . . L4 = {0, 2, 6} (where Si = {s1, s2, . . . , si} - the first i numbers in the input) Li is a subset of Li (i.e. Li ⊆ Li) Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li 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 Li L4 is a small subset of L4 and for any y ∈ L4, there is an z ∈ L4 with z y/2
  • 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 Li ⊆ Li) so that The length of Li is polynomial in the input length (i.e. |Li| nc for some c) For every y ∈ Li, there is a z ∈ Li which is almost as big (where Si = {s1, s2, . . . , si} - the first i numbers in the input) Li is a subset of Li (i.e. Li ⊆ Li) Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li iff where prev is the previous Li[j] > (1 + δ) · prev entry we included in Li
  • 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 Li ⊆ Li) so that The length of Li is polynomial in the input length (i.e. |Li| nc for some c) For every y ∈ Li, there is a z ∈ Li which is almost as big (where Si = {s1, s2, . . . , si} - the first i numbers in the input) Li is a subset of Li (i.e. Li ⊆ Li) Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li iff where prev is the previous Li[j] > (1 + δ) · prev entry we included in Li Unfortunately, this hasn’t really achieved anything. . .
  • 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 Li ⊆ Li) so that The length of Li is polynomial in the input length (i.e. |Li| nc for some c) For every y ∈ Li, there is a z ∈ Li which is almost as big (where Si = {s1, s2, . . . , si} - the first i numbers in the input) Li is a subset of Li (i.e. Li ⊆ Li) Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li iff where prev is the previous Li[j] > (1 + δ) · prev entry we included in Li 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)
  • 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 Li ⊆ Li) so that The length of Li is polynomial in the input length (i.e. |Li| nc for some c) For every y ∈ Li, there is a z ∈ Li which is almost as big (where Si = {s1, s2, . . . , si} - the first i numbers in the input) Li is a subset of Li (i.e. Li ⊆ Li) Consider this process called Trim. . . Trim(Li, δ): Include Li[j] in Li iff where prev is the previous Li[j] > (1 + δ) · prev entry we included in Li 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)
  • 98. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm ◦ Let Li = Trim(U, δ) Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li |S| = m
  • 99. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm ◦ Let Li = Trim(U, δ) Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li Trim(U, δ): Include U[j] in Li iff U[j] > (1 + δ) · prev where prev is the previous thing we included in Li |S| = m
  • 100. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm ◦ Let Li = Trim(U, δ) Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li |S| = m
  • 101. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm ◦ Let Li = Trim(U, δ) Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li 2 2 4 Li−1 = si = 3 |S| = m
  • 102. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm ◦ Let Li = Trim(U, δ) Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li 2 2 4 Li−1 = si = 3 2 (Li−1 + si) = 3 3 |S| = m
  • 103. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm ◦ Let Li = Trim(U, δ) Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li 2 2 4 Li−1 = si = 3 2 (Li−1 + si) = U = Li−1 ∪ (Li−1 + si) = 2 2 42 3 4 3 3 3 2 |S| = m
  • 104. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm ◦ Let Li = Trim(U, δ) Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li 2 2 4 Li−1 = si = 3 2 (Li−1 + si) = U = Li−1 ∪ (Li−1 + si) = 2 2 42 3 = Li = Trim(U, δ) 2 (with δ = 1) 4 3 3 3 2 2 3 |S| = m
  • 105. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm ◦ Let Li = Trim(U, δ) Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li 2 2 4 Li−1 = si = 3 2 (Li−1 + si) = U = Li−1 ∪ (Li−1 + si) = 2 2 42 3 = Li = 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
  • 106. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm ◦ Let Li = Trim(U, δ) Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li |S| = m
  • 107. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time ◦ Let Li = Trim(U, δ) Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li |S| = m
  • 108. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li−1|) time ◦ Let Li = Trim(U, δ) Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li |S| = m
  • 109. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li−1|) time O(|Li|) time ◦ Let Li = Trim(U, δ) Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li |S| = m
  • 110. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li−1|) time O(|Li|) time ◦ Let Li = Trim(U, δ) Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li Trim(U, δ): Include U[j] in Li iff U[j] > (1 + δ) · prev where prev is the previous thing we included in Li |S| = m
  • 111. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li−1|) time O(|Li|) time ◦ Let Li = Trim(U, δ) O(|Lm|) time Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li Trim(U, δ): Include U[j] in Li iff U[j] > (1 + δ) · prev where prev is the previous thing we included in Li |S| = m
  • 112. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li−1|) time O(|Li|) time ◦ Let Li = Trim(U, δ) O(|Lm|) time Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li |S| = m
  • 113. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li−1|) time O(|Li|) time This algorithm throws away some possible subsets, ◦ Let Li = Trim(U, δ) O(|Lm|) 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 - Li is the trimmed version of Li |S| = m
  • 114. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li−1|) time O(|Li|) time This algorithm throws away some possible subsets, Two questions remain. . . ◦ Let Li = Trim(U, δ) O(|Lm|) 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 - Li is the trimmed version of Li |S| = m
  • 115. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li−1|) time O(|Li|) time This algorithm throws away some possible subsets, Two questions remain. . . ◦ Let Li = Trim(U, δ) O(|Lm|) time but it always outputs a valid subset (but probably not the largest one) How big is |Li|? How good is the solution given? Let Li be the set of sizes of all S ⊆ Si which are not larger than t - Li is the trimmed version of Li |S| = m
  • 116. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y |S| = m
  • 117. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y For any entry in the original set (Li) . . . there is one in the trimmed set (Li) . . . of a ‘similar’ size (δ is very small) |S| = m
  • 118. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y |S| = m
  • 119. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) |S| = m
  • 120. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {0} |S| = m
  • 121. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {0} Inductive step: Assume that the lemma holds for (i − 1) |S| = m
  • 122. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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
  • 123. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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 ∈ Li−1 with y (1+δ)(i−1) x y |S| = m
  • 124. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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 ∈ Li−1 with y (1+δ)(i−1) x y by the inductive hypothesis |S| = m
  • 125. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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 ∈ Li−1 with y (1+δ)(i−1) x y |S| = m
  • 126. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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 ∈ Li−1 with y (1+δ)(i−1) x y By the definition of Trim there is some z ∈ Li with z x z · (1 + δ) |S| = m
  • 127. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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 ∈ Li−1 with y (1+δ)(i−1) x y By the definition of Trim there is some z ∈ Li with z x z · (1 + δ) So we have that z x y and z x 1+δ y (1+δ)i |S| = m
  • 128. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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 ∈ Li−1 with y (1+δ)(i−1) x y By the definition of Trim there is some z ∈ Li with z x z · (1 + δ) So we have that z x y and z x 1+δ y (1+δ)i |S| = m
  • 129. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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 ∈ Li−1 with y (1+δ)(i−1) x y By the definition of Trim there is some z ∈ Li with z x z · (1 + δ) So we have that z x y and z x 1+δ y (1+δ)i |S| = m
  • 130. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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 ∈ Li−1 with y (1+δ)(i−1) x y By the definition of Trim there is some z ∈ Li with z x z · (1 + δ) So we have that z x y and z x 1+δ y (1+δ)i |S| = m
  • 131. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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 ∈ Li−1 with y (1+δ)(i−1) x y By the definition of Trim there is some z ∈ Li with z x z · (1 + δ) So we have that z x y and z x 1+δ y (1+δ)i |S| = m
  • 132. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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 ∈ Li−1 with y (1+δ)(i−1) x y By the definition of Trim there is some z ∈ Li with z x z · (1 + δ) So we have that z x y and z x 1+δ y (1+δ)i |S| = m
  • 133. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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 ∈ Li−1 with y (1+δ)(i−1) x y By the definition of Trim there is some z ∈ Li 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 ∈ Li with y (1+δ)i z y as required |S| = m
  • 134. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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 ∈ Li−1 with y (1+δ)(i−1) x y By the definition of Trim there is some z ∈ Li 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 ∈ Li with y (1+δ)i z y as required |S| = m
  • 135. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y Proof (by induction) Base Case: L0 = L0 = {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 ∈ Li−1 with y (1+δ)(i−1) x y By the definition of Trim there is some z ∈ Li 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 ∈ Li with y (1+δ)i z y as required |S| = m
  • 136. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y |S| = m
  • 137. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y By setting i = m and δ = /2m we have that, For any y ∈ Lm there is a z ∈ Lm with y (1 + 2m )m z y |S| = m
  • 138. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y By setting i = m and δ = /2m we have that, For any y ∈ Lm there is a z ∈ Lm with y (1 + 2m )m z y Further, Opt ∈ Lm meaning there is a z ∈ Lm with Opt 1 + 2m m z Opt |S| = m
  • 139. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y By setting i = m and δ = /2m we have that, For any y ∈ Lm there is a z ∈ Lm with y (1 + 2m )m z y Further, Opt ∈ Lm meaning there is a z ∈ Lm with Opt 1 + 2m m z Opt Recall that the output of the algorithm is the largest number in Lm. . . |S| = m
  • 140. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y By setting i = m and δ = /2m we have that, For any y ∈ Lm there is a z ∈ Lm with y (1 + 2m )m z y Further, Opt ∈ Lm meaning there is a z ∈ Lm 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 Lm. . . |S| = m
  • 141. Li vs. Li Lemma For any y ∈ Li there is an z ∈ Li with y (1+δ)i z y By setting i = m and δ = /2m we have that, For any y ∈ Lm there is a z ∈ Lm with y (1 + 2m )m z y Further, Opt ∈ Lm meaning there is a z ∈ Lm 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 Lm. . . |S| = m VS Opt 1 + z Opt
  • 142. Li vs. Li We need to show that 1 + 2m m 1 + (for 0 < 1) |S| = m
  • 143. Li vs. Li We need to show that 1 + 2m m 1 + (for 0 < 1) 1 + 2m m e /2 1+ 2 + 2 2 1+ |S| = m
  • 144. Li vs. Li 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
  • 145. Li vs. Li 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
  • 146. Li vs. Li 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
  • 147. Li vs. Li 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
  • 148. Li vs. Li 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
  • 149. How big is Li? The time complexity depends on |Li|. . . |S| = m
  • 150. How big is Li? The time complexity depends on |Li|. . . By the definition of Trim we have that, any two successive elements, z, z of Li have z z 1 + δ = 1 + 2m |S| = m
  • 151. How big is Li? The time complexity depends on |Li|. . . By the definition of Trim we have that, any two successive elements, z, z of Li have z z 1 + δ = 1 + 2m Further, all elements are no greater than t |S| = m
  • 152. How big is Li? The time complexity depends on |Li|. . . By the definition of Trim we have that, any two successive elements, z, z of Li have z z 1 + δ = 1 + 2m Further, all elements are no greater than t So Li contains at most O(log(1+δ) t) elements |S| = m
  • 153. How big is Li? The time complexity depends on |Li|. . . By the definition of Trim we have that, any two successive elements, z, z of Li have z z 1 + δ = 1 + 2m Further, all elements are no greater than t So Li 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
  • 154. How big is Li? The time complexity depends on |Li|. . . By the definition of Trim we have that, any two successive elements, z, z of Li have z z 1 + δ = 1 + 2m Further, all elements are no greater than t So Li 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
  • 155. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li|) time O(|Li|) time ◦ Let Li = Trim(U, δ) O(|Lm|) time |S| = m
  • 156. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li|) time O(|Li|) time As |Li| = O(m log t/ ), the algorithm runs in ◦ Let Li = Trim(U, δ) O(|Lm|) time O(m2 log t/ ) = O(n3 log n/ ) time |S| = m
  • 157. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li|) time O(|Li|) time As |Li| = O(m log t/ ), the algorithm runs in ◦ Let Li = Trim(U, δ) O(|Lm|) 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)
  • 158. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li|) time O(|Li|) time As |Li| = O(m log t/ ), the algorithm runs in ◦ Let Li = Trim(U, δ) O(|Lm|) time O(m2 log t/ ) = O(n3 log n/ ) time |S| = m
  • 159. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li|) time O(|Li|) time As |Li| = O(m log t/ ), the algorithm runs in The output z is such that ◦ Let Li = Trim(U, δ) O(|Lm|) time O(m2 log t/ ) = O(n3 log n/ ) time Opt 1 + z Opt |S| = m
  • 160. A PTAS for Subset Sum The algorithm ◦ Let L0 = {0}, δ = /(2m) ◦ For i = 1 . . . m: ◦ Compute (Li−1 + si) from Li−1 ◦ Compute U = Li−1 ∪ (Li−1 + si) ◦ Output the largest number in Lm O(|Li−1|) time O(|Li|) time O(|Li|) time As |Li| = O(m log t/ ), the algorithm runs in The output z is such that ◦ Let Li = Trim(U, δ) O(|Lm|) 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
  • 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
  翻译: