Question: Design an algorithm such that Input: array A[1..n] of positive integers and a positive integer C; Output: the smallest integer m such that there are

Design an algorithm such that

Input: array A[1..n] of positive integers and a positive integer C;

Output: the smallest integer m such that there are m elements in A that sum up to C or is there are no such elements.

The complexity of the algorithm should be O(nC). For example, if A = [1,3,1,5,2] and C = 7, then the output will be 2 because 7 can be written as 5 + 2.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!