Subj : Re: combinations of array elements To : comp.programming From : Thad Smith Date : Sun Aug 07 2005 07:43 pm William wrote: > Given a array of integers. How will you find all the combinations of the > array elements whose sum also lie in that array ? > e.g. for 4, 1, 3, 2, 10, you would have: > 1, 3 > 1, 2 > 4, 1, 3, 2 If the array is small enough, it makes sense to explicitly try all the combinations. You might want to use a bit array, hash table, or binary search for testing the sum. For large arrays, you might want to use some sort of meet in the middle attack. Thad .