• recategorized by
277 views
0 0 votes
The input to the problem consists of (i) an array $A[1,2, \ldots, n]$ of $n$ positive integers and (ii) a positive integer $T$. We are given the guarantee that at least one element of the array is less than or equal to $T$. The task is to find the maximum sum of a non-empty sub-collection of the integers from $A$ which is less than or equal to $T$.

Describe an algorithm that solves this problem in $O(n T)$ time. The algorithm should take an array $A[1,2, \ldots, n]$ and an integer $T$ as described above, and should output a number $T^{\prime} \leq T$ that is closest to $T$ and can be realized as the sum of some subcollection of $A$. It is not required that the algorithm find the subset of indices which forms the sum $T^{\prime}$.

Please log in or register to answer this question.

Position:
Show:

Related questions

0 0 votes
1 1 answer
210
210 views
admin asked Nov 13, 2024
210 views
Consider the following code which computes a function f . The input to f is an array $\mathrm{A}[1 . \mathrm{m}]$ which represents a number N in ternary. For example, $\m...
0 0 votes
0 0 answers
150
150 views
Ay_Kay_Ay asked Dec 2, 2024
150 views
Let $\mathrm{A}, \mathrm{B}$ and C denote arrays of real numbers, where B has $\mathrm{n}-1$ entries and $\mathrm{A}, \mathrm{C}$ have n entries each. Consider the follow...
0 0 votes
1 1 answer
246
246 views
admin asked Nov 13, 2024
246 views
You are starting a new bus service. You are hiring drivers and conductors. A driver and a conductor can run a bus only if they can speak a common language. There are $n$ ...
0 0 votes
1 1 answer
170
170 views
Ay_Kay_Ay asked Dec 2, 2024
170 views
In the following pseudocode segment, A denotes an array and len(A) denotes the number of elements in that array. The array is indexed from $1$ to len(A). Write down the a...