Question: 2 . 1 Problem 3 [ 1 5 p t s ] Problem 3 . Consider the Knapsack problem with the following inputs: A list
Problem
Problem Consider the Knapsack problem with the following inputs:
A list of items: dots, where is the value and is the weight of the th item.
A weight limit
The goal is to select a subset Ssubedots, such that:
maximizes the total value:
Consider the following greedy algorithm for this problem:
Order the items by their valueperweight ratio, in descending order.
Select items in this order, adding them to as long as the total weight remains within the limit
Provide an example demonstrating that this greedy algorithm does not always yield the optimal solution.
Include the example, show the steps of the greedy algorithm on it and present a solution with a higher total value
that adheres to the weight limit
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
