<s>
The	O
subset	B-Algorithm
sum	I-Algorithm
problem	I-Algorithm
(	O
SSP	O
)	O
is	O
a	O
decision	O
problem	O
in	O
computer	B-General_Concept
science	I-General_Concept
.	O
</s>
<s>
In	O
its	O
most	O
general	O
formulation	O
,	O
there	O
is	O
a	O
multiset	B-Language
of	O
integers	O
and	O
a	O
target-sum	O
,	O
and	O
the	O
question	O
is	O
to	O
decide	O
whether	O
any	O
subset	O
of	O
the	O
integers	O
sum	O
to	O
precisely	O
.	O
</s>
<s>
This	O
special	O
case	O
of	O
SSP	O
is	O
known	O
as	O
the	O
partition	B-Algorithm
problem	I-Algorithm
.	O
</s>
<s>
SSP	O
is	O
a	O
special	O
case	O
of	O
the	O
knapsack	B-Algorithm
problem	I-Algorithm
and	O
of	O
the	O
multiple	B-Algorithm
subset	I-Algorithm
sum	I-Algorithm
problem	I-Algorithm
.	O
</s>
<s>
If	O
n	O
is	O
a	O
small	O
fixed	O
number	O
,	O
then	O
an	O
exhaustive	B-Algorithm
search	I-Algorithm
for	O
the	O
solution	O
is	O
practical	O
.	O
</s>
<s>
If	O
L	O
is	O
a	O
small	O
fixed	O
number	O
,	O
then	O
there	O
are	O
dynamic	B-Algorithm
programming	I-Algorithm
algorithms	O
that	O
can	O
solve	O
it	O
exactly	O
.	O
</s>
<s>
This	O
can	O
also	O
be	O
proved	O
by	O
reduction	O
from	O
the	O
general	O
variant	O
;	O
see	O
partition	B-Algorithm
problem	I-Algorithm
.	O
</s>
<s>
The	O
most	O
naïve	B-Algorithm
algorithm	I-Algorithm
would	O
be	O
to	O
cycle	O
through	O
all	O
subsets	O
of	O
n	O
numbers	O
and	O
,	O
for	O
every	O
one	O
of	O
them	O
,	O
check	O
if	O
the	O
subset	B-Algorithm
sums	I-Algorithm
to	O
the	O
right	O
number	O
.	O
</s>
<s>
The	O
algorithm	O
can	O
be	O
implemented	O
by	O
depth-first	B-Algorithm
search	I-Algorithm
of	O
a	O
binary	O
tree	O
:	O
each	O
level	O
in	O
the	O
tree	O
corresponds	O
to	O
an	O
input	O
number	O
;	O
the	O
left	O
branch	O
corresponds	O
to	O
excluding	O
the	O
number	O
from	O
the	O
set	O
,	O
and	O
the	O
right	O
branch	O
corresponds	O
to	O
including	O
the	O
number	O
(	O
hence	O
the	O
name	O
Inclusion-Exclusion	O
)	O
.	O
</s>
<s>
Rather	O
than	O
generating	O
and	O
storing	O
all	O
subsets	O
of	O
n/2	O
elements	O
in	O
advance	O
,	O
they	O
partition	O
the	O
elements	O
into	O
4	O
sets	O
of	O
n/4	O
elements	O
each	O
,	O
and	O
generate	O
subsets	O
of	O
n/2	O
element	O
pairs	O
dynamically	O
using	O
a	O
min	B-Application
heap	I-Application
,	O
which	O
yields	O
the	O
above	O
time	O
and	O
space	O
complexities	O
since	O
this	O
can	O
be	O
done	O
in	O
and	O
space	O
given	O
4	O
lists	O
of	O
length	O
k	O
.	O
</s>
<s>
Howgrave-Graham	O
and	O
Joux	O
presented	O
a	O
probabilistic	B-General_Concept
algorithm	I-General_Concept
that	O
runs	O
faster	O
than	O
all	O
previous	O
ones	O
-	O
in	O
time	O
using	O
space	O
.	O
</s>
<s>
It	O
solves	O
only	O
the	O
decision	O
problem	O
,	O
cannot	O
prove	O
there	O
is	O
no	O
solution	O
for	O
a	O
given	O
sum	O
,	O
and	O
does	O
not	O
return	O
the	O
subset	B-Algorithm
sum	I-Algorithm
closest	O
to	O
T	O
.	O
</s>
<s>
SSP	O
can	O
be	O
solved	O
in	O
pseudo-polynomial	B-Algorithm
time	I-Algorithm
using	O
dynamic	B-Algorithm
programming	I-Algorithm
.	O
</s>
<s>
BFS	B-Algorithm
)	O
to	O
search	O
the	O
state	O
(	O
N	O
,	O
T	O
)	O
.	O
</s>
<s>
However	O
,	O
Subset	B-Algorithm
Sum	I-Algorithm
encoded	O
in	O
unary	O
is	O
in	O
P	O
,	O
since	O
then	O
the	O
size	O
of	O
the	O
encoding	O
is	O
linear	O
in	O
B-A	O
.	O
</s>
<s>
Hence	O
,	O
Subset	B-Algorithm
Sum	I-Algorithm
is	O
only	O
weakly	O
NP-Complete	O
.	O
</s>
<s>
In	O
2015	O
,	O
Koiliaris	O
and	O
Xu	O
found	O
a	O
deterministic	O
algorithm	O
for	O
the	O
subset	B-Algorithm
sum	I-Algorithm
problem	I-Algorithm
where	O
is	O
the	O
sum	O
we	O
need	O
to	O
find	O
.	O
</s>
<s>
In	O
2014	O
,	O
Curtis	O
and	O
Sanches	O
found	O
a	O
simple	O
recursion	O
highly	O
scalable	O
in	O
SIMD	B-Device
machines	O
having	O
time	O
and	O
space	O
,	O
where	O
is	O
the	O
number	O
of	O
processing	O
elements	O
,	O
and	O
is	O
the	O
lowest	O
integer	O
.	O
</s>
<s>
An	O
approximation	B-Algorithm
algorithm	I-Algorithm
to	O
SSP	O
aims	O
to	O
find	O
a	O
subset	O
of	O
S	O
with	O
a	O
sum	O
of	O
at	O
most	O
T	O
and	O
at	O
least	O
r	O
times	O
the	O
optimal	O
sum	O
,	O
where	O
r	O
is	O
a	O
number	O
in	O
(	O
0	O
,	O
1	O
)	O
called	O
the	O
approximation	B-Algorithm
ratio	I-Algorithm
.	O
</s>
<s>
The	O
following	O
very	O
simple	O
algorithm	O
has	O
an	O
approximation	B-Algorithm
ratio	I-Algorithm
of	O
1/2	O
:	O
</s>
<s>
The	O
following	O
algorithm	O
attains	O
,	O
for	O
every	O
,	O
an	O
approximation	B-Algorithm
ratio	I-Algorithm
of	O
.	O
</s>
<s>
Recall	O
that	O
n	O
is	O
the	O
number	O
of	O
inputs	O
and	O
T	O
is	O
the	O
upper	O
bound	O
to	O
the	O
subset	B-Algorithm
sum	I-Algorithm
.	O
</s>
<s>
It	O
ensures	O
that	O
all	O
sums	O
remaining	O
in	O
L	O
are	O
below	O
T	O
,	O
so	O
they	O
are	O
feasible	O
solutions	O
to	O
the	O
subset-sum	B-Algorithm
problem	I-Algorithm
.	O
</s>
<s>
Then	O
,	O
the	O
polynomial	O
time	O
algorithm	O
for	O
approximate	O
subset	B-Algorithm
sum	I-Algorithm
becomes	O
an	O
exact	O
algorithm	O
with	O
running	O
time	O
polynomial	O
in	O
and	O
(	O
i.e.	O
,	O
exponential	O
in	O
)	O
.	O
</s>
<s>
Kellerer	O
,	O
Mansini	O
,	O
Pferschy	O
and	O
Speranza	O
and	O
Kellerer	O
,	O
Pferschy	O
and	O
Pisinger	O
present	O
other	O
FPTAS-s	O
for	O
subset	B-Algorithm
sum	I-Algorithm
.	O
</s>
