# SubsetSum - Problem Subset Sum Given A set S = cfw_s1 s2 sn...

This preview shows pages 1–2. Sign up to view the full content.

Problem: Subset Sum Given: A set S = {s 1 , s 2 , …, s n }, for n 1, of positive integers, and an integer B. Question: Does there exist a subset of S whose items sum to B? Denote an instance of this problem by a Boolean variable SS(s 1 , s 2 , …, s n , B) which is true if and only if there exists a subset of the values s 1 , s 2 ,…, s n that sum to the value B. Notice, when n = 1, we define SS(s 1 , s 2 , …, s n , B) to be true exactly when B = s n . Theorem: For n 2, SS(s 1 , s 2 , …, s n , B) is true if and only if SS(s 1 , s 2 , …, s n-1 , B) or SS(s 1 , s 2 , …, s n-1 , B–s n ) is true. Proof: First, suppose for some arbitrary instance, that SS(s 1 , s 2 , …, s n , B) is true. By the definition, there is a set A S = {s 1 , s 2 , …, s n } so that the sum of the items in A is B. Either A contains s n , or it does not. If s n A, then the sum of the items in A–{s n } must be B–s n . Therefore, since A–{s n } {s 1 , s 2 , …, s n-1 }, SS(s 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

SubsetSum - Problem Subset Sum Given A set S = cfw_s1 s2 sn...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online