im having a problem concerning recursion in C++. I ve encountered a problem that requires to find all the subsets of a set of intergers that gives a required sum, meaning..
Enter integers: 16, 3,3,13.
Required sum: 19
The prog should output:
the maximum size of the array is 20. i want to out allll the susbsets that their sume is equal to that required sum entered by the user..i cant think of an algorithim but i have some ideas of what should be done;
1) the array(or a linked list) should be sorted ascendingly
2) a friend of mine suggested using stacks but i dnot know how to do it exactly..
2) the no. of subsets is equal to 2^n, while n is the no. of elements entered by the user.(maximum no. of subsets is 2^20)
3) the no . of each subset is found by combinations .
thats all ..please if you have an idea of how to solve this prob by recursion you will make my day!!