subject

Given n items with weights w1, w2, and wn, and a bag with a weight capacity of w, the problem of finding the items with the maximum total weight to store in the bag is called the 0/1 knapsack problem. Let m(i, w) denote the total weight of the best solution of placing the first i items into a bag with weight capacity w. The problem can be solved using the following recursion: m(0, weightLimit) 0; m(i, w)m(i-1, weightLimit) if wi> weightLimit Write a recursive method for computing m(i, w) using following method header: public static double m(int i, double weightimit, doublell w) where w is an array of the weights for items. Write a test program that prompts the user to enter the number of the items and weight for each item and the weight capacity of the bag, and displays the maximum total weight of the items that can be placed in the bag. Your output should look like that below:
Enter the number of items:6
Enter the weights for each item: 2 38495
Enter the weight limit for the bag: 7
The maximum weight of the items placed in the bag is 7.0

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:30
What type of computer network ensures high security ?
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Spoons are designed to be used for: spring hammering. applying body filler. identifying high and low spots. sanding highly formed areas.
Answers: 3
question
Computers and Technology, 24.06.2019 09:00
Why might you chose to crest a function resume
Answers: 1
question
Computers and Technology, 24.06.2019 10:40
Joe needs to see the slide transitions and animations he has applied to his slides in a large view. which presentation view should he use? in which tab would joe find the animations option to make further changes, if any?
Answers: 1
You know the right answer?
Given n items with weights w1, w2, and wn, and a bag with a weight capacity of w, the problem of fin...
Questions
question
World Languages, 04.09.2021 14:00
question
Chemistry, 04.09.2021 14:00
question
English, 04.09.2021 14:00
question
Mathematics, 04.09.2021 14:00
question
English, 04.09.2021 14:00
Questions on the website: 13722359