Cool_Happy wrote:
> Suppose u r given a positive number N.
> How will we find a set of distinct positive numbers having sum equal
> to N.
> There could be multiple such sets so what is the algo to find all
> those sets.
As one poster wrote, you're just looking to find all integer
partitions (with
I hope this solution will find the all the subsets from set S . The sum of
elements in subset is equivalent to certain no. k.
fun(int a[],int k){
int i,j;
int k1;
for(i=0;i<10;i++){
k1=a[i];
j=i+1;
> Suppose u r given a positive number N.
> How will we find a set of distinct positive numbers having sum equal
> to N.
> There could be multiple such sets so what is the algo to find all
> those sets.
Yes, this is the subset-sum problem but all is not lost.
There is a dynamic programming soluti
This is a Subset-Summation problem which is proven to be NP-Complete.
So there are no ways that you can devise a clever algo to solve it
accurately.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks"
Google search for Integer Partitions.
On Apr 30, 9:04 am, Cool_Happy <[EMAIL PROTECTED]> wrote:
> Suppose u r given a positive number N.
> How will we find a set of distinct positive numbers having sum equal
> to N.
> There could be multiple such sets so what is the algo to find all
> those sets.
If I understand correctly this is subset-sum problem and is NP-
Complete.
On Apr 30, 9:04 am, Cool_Happy <[EMAIL PROTECTED]> wrote:
> Suppose u r given a positive number N.
> How will we find a set of distinct positive numbers having sum equal
> to N.
> There could be multiple such sets so what