|
-
January 26th, 2015, 12:14 AM
#1
Using a linear median algorithm to find the largest subset for some given sum
Suppose an array A of n numbers is given along with an integer M. Assume that an algorithm which finds the median of an unsorted array in linear time is also given. Design a O(n) algorithm that finds the largest subset S = {1, 2, · · · , n} satisfying ∑(i belonging to S) A[i] <= M.
∑ is sum symbol. I can find a algorithm like search to satisfy the time complexity.
Anyone have some simple way to fix it?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|