Question: Suppose that we have a knapsack with total capacity of W kg. We also have n items where item j has mass wj. The knapsack

Suppose that we have a knapsack with total capacity of W kg. We also have n items where item j has mass wj. The knapsack problem asks for a subset of these n items with the largest possible total mass not exceeding W.
a) Devise a brute-force algorithm for solving the knapsack problem.
b) Solve the knapsack problem when the capacity of the knapsack is 18 kg and there are five items: a 5-kg sleeping bag, an 8-kg tent, a 7-kg food pack, a 4-kg container of water, and an 11-kg portable stove.

Step by Step Solution

3.47 Rating (160 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a We want to maximize the mass of the contents of the knapsack So we can try each possible subset ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (1 attachment)

Word file Icon

923-M-C-M-S (1601).docx

120 KBs Word File

Students Have Also Explored These Related Statistics Questions!