There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code. Flon's Law

Subset Sum

Language Java | Level Intermediate | Category Algorithms | August 3, 2015 10:08 pm


Algorithm Problem Description

Find the non-empty subset whose sum is zero from given set of the integers. For example, given the set {?7, ?3, ?2, 5, 8}, the answer is yes because the subset {?3, ?2, 5} sums to zero.

This problem is an example of NP-complete. Write a program to give the total of values equal to sum S.

Output

          	        
          	        

The Goal is : 0
0=true
The Goal is : 1
1=false
The Goal is : 2
2 2=true
The Goal is : 3
3=false
The Goal is : 4
4=false
The Goal is : 5
5 5=true
The Goal is : 6
6=false
The Goal is : 7
5 2 7=true
The Goal is : 8
8 8=true
The Goal is : 9
9 9=true

          	        
          	        				    


Comments



Please login to add comments.