Question: ( 0 - 1 Knapsack ) The program will be to solve the 0 - 1 knapsack problem using a branch - and - bound
Knapsack
The program will be to solve the knapsack problem using a branchandbound strategy. The
program will take as input a file containing a number of items, the capacity of the knapsack and
the individual items. Each individual item will be on a separate row and consist of a label, then a
value then a weight. The label will contain no blank spaces. The output will be a simple message
stating the items that should be included in the knapsack and the total weight and value of the
knapsack.
Example Data knapSacktxt
A
B
C
AA
BB
CC
AAA
Input
Input file name: knapSacktxt
Output:
Item included in knapsack: B AA BB
Total weight
Total value
Specifications:
Program driver will be called KnapsackDriver.java
The included items must be listed in descending order of their profit to weight ratio.
The program will prompt the user for input files.
Program must utilize a bestfirst branchandbound strategy.
The program is due May st and there will be no late program accepted. This is a hard deadline
so dont wait till the last day to work on your program.
Additional required methods an overloaded method printItem this method will take an
argument of the either the item number based on the order a descending order of the ratio of
the items, or a string containing the item label. The method will print the label, price, and
weight and the ratio formatted to decimal point. For example printItemBB would print out
BB and printItem would print out C
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
