Upload
ryan-gatchalian
View
220
Download
0
Embed Size (px)
Citation preview
8/2/2019 466-lect25
1/5
+ +
C S 4 6 6 L e c t u r e N o t e s , S p r i n g 1 9 9 5 . L e c t u r e 2 5
S U B S E T - S U M i s N P - c o m p l e t e . R e f e r e n c e : S e c -
t i o n 3 6 . 5 . 3 o f C L R .
D e n i t i o n . T h e S U B S E T - S U M p r o b l e m i s
t h e f o l l o w i n g : y o u a r e g i v e n a s e t o f p o s i t i v e
i n t e g e r s S a n d a \ t a r g e t " t . Q u e s t i o n :
I s t h e r e a s u b s e t S
0
o f S s u c h t h a t t h e s u m
o f t h e e l e m e n t s o f S
0
i s e q u a l t o t ?
T h e o r e m . T h e S U B S E T - S U M p r o b l e m i s N P -
c o m p l e t e .
T o p r o v e t h i s , w e f o l l o w t h e \ v e - s t e p s " .
1 . S U B S E T - S U M i s i n N P . T o p r o v e t h i s , o b s e r v e t h a t
i f s o m e o n e g i v e s u s t h e s e t S
0
, w e c a n i n p o l y n o m i a l
t i m e d e t e r m i n e t h e s u m o f t h e e l e m e n t s i n S
0
, a n d s e e
i f t h a t i s e q u a l t o t
+ 1
8/2/2019 466-lect25
2/5
+ +
2 . W e w i l l s h o w V E R T E X - C O V E R
p
S U B S E T - S U M .
3 . W e n e e d t o s h o w h o w t o t r a n s f o r m a n i n s t a n c e o f
V E R T E X - C O V E R t o a n i n s t a n c e o f S U B S E T - S U M .
A V E R T E X - C O V E R i n s t a n c e i s a p a i r < G ; k > . O u r
c o n s t r u c t i o n w i l l b e b a s e d o n t h e i n c i d e n c e m a t r i x o f
t h e g r a p h G = ( V ; E ) . T h e i n c i d e n c e m a t r i x M
i j
i s a
j V j j E j m a t r i x t h a t i s d e n e d a s f o l l o w s :
M
i j
=
1 i f e d g e e
j
i s i n c i d e n t o n v e r t e x v
i
0 o t h e r w i s e .
( 1 )
S e e F i g u r e 3 6 . 1 4 , p a g e 9 5 2 o f C L R .
N o t i c e t h a t e a c h r o w o f t h e i n c i d e n c e m a t r i x c o r r e -
s p o n d s t o t h e e d g e s t o u c h i n g a g i v e n v e r t e x .
W e n o w c o n s t r u c t a s e t S o f n u m b e r s a n d a t a r g e t t
s u c h t h a t t h e r e i s a s o l u t i o n t o t h e s u b s e t - s u m p r o b l e m
< S ; t > i t h e o r i g i n a l g r a p h G h a s a v e r t e x - c o v e r o f
s i z e k
+ 2
8/2/2019 466-lect25
3/5
+ +
W e d o t h i s a s f o l l o w s :
S = f x
0
; : : : ; x
j V j 1
g f y
0
; : : : ; y
j E j 1
g ;
w h e r e
x
i
= 4
j E j
+
j E j 1
X
j = 0
M
i j
4
j
f o r 0 i
8/2/2019 466-lect25
4/5
+ +
W e c l a i m t h i s s u b s e t S
0
s u m s t o t . T o p r o v e t h i s ,
c o n v i n c e y o u r s e l f t h a t w e c a n c h e c k t h i s c l a i m o n e a c h
d i g i t o f t h e e l e m e n t s o f S . ( T h e c a r r i e s d o n o t i n t e r f e r e
s i n c e a t m o s t 3 e l e m e n t s o f S h a v e a 1 i n d i g i t p o s i t i o n
j , f o r a l l j l e s s t h a n j E j . ) S i n c e t h e o r i g i n a l g r a p h G h a s
a v e r t e x c o v e r o f s i z e k , t h e m o s t s i g n i c a n t d i g i t ( s )
o f t h e s u m s a r e k , a n d t h i s m a t c h e s t h e t a r g e t . S i n c e
s i n c e V
0
i s a v e r t e x c o v e r , e a c h e d g e ( i . e . c o l u m n ) h a s
a t l e a s t o n e v e r t e x i n V
0
( i . e . r o w s u m ) t h a t t o u c h e s
i t ( i . e . h a s a 1 i n t h a t d i g i t p o s i t i o n ) . I t m i g h t h a v e
t w o , i n w h i c h c a s e n o n e o f t h e y
j
' s i n S
0
h a v e a 1 i n
t h a t p o s i t i o n , b y o u r d e n i t i o n o f S
0
. I f i t i s h a s o n l y
o n e 1 , t h e n a n o t h e r 1 i s a d d e d b y t h e a p p r o p r i a t e y
j
T h u s f o r a l l d i g i t p o s i t i o n s e x c e p t t h e m o s t s i g n i c a n t
o n e ( s ) , t h e c o l u m n s u m i s 2 . T h i s m a t c h e s t h e t a r g e t .
T o p r o v e t h e o t h e r d i r e c t i o n , a s s u m e t h a t t h e r e i s a
s u b s e t S
0
t h a t m a t c h e s t h e t a r g e t . D e n e
V
0
= f v
i
: n u m b e r x
i
2 S
0
g
T h e n V
0
i s a v e r t e x c o v e r . S i n c e t h e t a r g e t h a s a \ k " i n
t h e m o s t s i g n i c a n t d i g i t , t h i s c o r r e s p o n d s t o p i c k i n g
e x a c t l y k o f t h e x
i
. T h u s V
0
h a s e x a c t l y k e l e m e n t s .
T o s e e t h a t V
0
i s a v e r t e x c o v e r , l e t e
j
b e a n e d g e i n
G . T h e n t h e r e i s a 2 i n e v e r y o t h e r d i g i t p o s i t i o n o f
t h e t a r g e t e x c e p t t h e m o s t s i g n i c a n t o n e ( s ) . S i n c e
t h e r e a r e o n l y t h r e e e l e m e n t s o f S t h a t h a v e a 1 i n
d i g i t p o s i t i o n j ( n a m e l y , x
r
a n d x
s
, w h e r e e
j
= ( r ; s ) ,
a n d y
j
) , a t l e a s t 1 o f t h e t o t a l c o n t r i b u t i o n o f 2 m u s t
c o m e f r o m a n x
i
2 S
0
. H e n c e e
j
t o u c h e s v
i
, a n d v
i
i s i n
V
0
. T h i s c o m p l e t e s t h e p r o o f t h a t V
0
i s a v e r t e x c o v e r .
2
+ 4
8/2/2019 466-lect25
5/5
5 . C o n v i n c e y o u r s e l f t h a t t h i s t r a n s f o r m a t i o n ( f r o m
a n i n s t a n c e o f V E R T E X - C O V E R t o a n i n s t a n c e o f
S U B S E T - S U M ) c a n b e d o n e i n p o l y n o m i a l t i m e . 2
T h u s , S U B S E T - S U M i s N P - c o m p l e t e . T h i s i s r a t h e r
r e m a r k a b l e , w h e n o n e c o n s i d e r s t h a t t h e s u b s e t - s u m
p r o b l e m d e a l s w i t h s u m s o f n u m b e r s , a n d i s q u i t e f a r
a w a y f r o m o u r o r i g i n a l N P - c o m p l e t e p r o b l e m o f c i r c u i t
s a t i s a b i l i t y !