[Solved] Write a function which computes the perfect sums in an array?


It is a variation of Subset-Sum problem – with an additional constraint on the size of the subset (larger then 1).

The problem is NP-Complete, but for relatively small integers can be solved using Dynamic Programming in pseudo-polynomial time.

A possibly simpler alternative which is feasible for small arrays is brute-force – just search all possible subsets, and verify for each if it matches the sum.

I believe these guidelines are more then enough as a starter for you to start programming the problem and solve your problem (HW?) on your own.

Good luck.

solved Write a function which computes the perfect sums in an array?