Question: The only data structures you can use are heaps and dictionaries. Please remember do pesudo code 5 Problem 5 (30 points) Consider the following problem
The only data structures you can use are heaps and dictionaries. Please remember do pesudo code

5 Problem 5 (30 points) Consider the following problem ThresholdSum(A,T) Input: - An array A witn n numbers. You can assume that all the numbers are positive and that they are all distinct (no duplicates). The input array is NOT sorted. - Positive number T. Output: the smallest positive integer k such that the largest k elements of A sum to at least >T. For example, if A = 6, 20, 10, 1, 7, 13,5 then ThresholdSum(A,45) = 4 because the four largest numbers in A are 7, 10, 13, 20 and 7+10+13+20 = 50 > 45. But if you had just taken the three largest numbers you would have 10+13+ 20 = 43
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
