ok, so this is my problem...
i have an array of items, which i want to sum to x or above in a most efficient way...
is there a way for doing this? cause all the values are 64 bit ints.
i tried recursion but it's slow cause i can have up to 200 items :( helppp!!
gregorynoob
2
Junior Poster in Training
Recommended Answers
Jump to Postwhy use recursion when a simple loop will do. Loops are always faster than recursion (and less memory/stack intensive too).
Jump to Posta simple loop? could you please tell me what algorithm would that be? cause recursion would go O(n!), would have to check all the combinations, also i didn't say, there are no unlimited supplies of items like in usual knapsack.
O (n!) when using recursion? I either don't understand the …
All 6 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
gregorynoob
2
Junior Poster in Training
VernonDozier
2,218
Posting Expert
Featured Poster
gregorynoob
2
Junior Poster in Training
vijayan121
1,152
Posting Virtuoso
VernonDozier
2,218
Posting Expert
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.