by eturo
Before I will end my day, I would like to share a program source code to solve a problem which I think it's a little bit complicated. This was given when I once attended a seminar-workshop in our region. I made a Java applet for the said problem as shown below.
Computing All Subset Sums
Problem: Given an array containing some integers (there may be duplicates), write a" routine that returns all the possible sums that can be formed by using numbers in the array. For instance, if the array contains 4 and 6, the possible sums are n0, 4, 6, and 10." If the array contains 1, 3, 5, and 7, the possible sums are 0, 1, 3, 5, 7, 4, 6, 8, 8, 10, 12, 9, 11, 13, 15, and 16. Notice that 8 appears twice in the answer (1+7 and 3+5).".
The Design: