Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You are given a list AA positive integers a1,,ana1,,an, and a positive integer BB. A subset S{1,2,,n}S{1,2,,n} is called feasible if its weight doen't exceed
You are given a list AA positive integers a1,,ana1,,an, and a positive integer BB. A subset S{1,2,,n}S{1,2,,n} is called feasible if its weight doen't exceed BB, i.e., if
iSaiB.iSaiB.
Your goal is to find a feasible subset S{1,2,,n}S{1,2,,n} such that
iSaiM/2,iSaiM/2,
where MM is the maximum weight achievable by any feasible subset.
Give an algorithm to solve this problem in time O(n)O(n).
Q4 (10 points) You are given a list A positive integers a1, ..., An, and a positive integer B. A subset S C{1,2,...,n} is called feasible if its weight doen't exceed B, i.e., ifStep 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