SubsetSum - Problem: Subset Sum Given: A set S = cfw_s1,...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

SubsetSum - Problem: Subset Sum Given: A set S = cfw_s1,...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online