Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write pseudocode for a recurssive algorithm that solves the above problem in O(n) time. Consider the following problem ThresholdSum(A,T) Input: An array A witn n
Write pseudocode for a recurssive algorithm that solves the above problem in O(n) time.
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 = 43Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started