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

The only data structures you can use are heaps and dictionaries. Please

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

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!