Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A thief rubbing a safe finds it filled with N types of items of varying size and value, but has only a small knapsack of

image text in transcribed
A thief rubbing a safe finds it filled with N types of items of varying size and value, but has only a small knapsack of capacity M to use to carry the goods. The knapsack problem is to find the combination of items which the thief should choose for the knapsack in order to maximize the total value of the stolen items. you are going to develop an algorithm and create the necessary data structures to solve the knapsack problem with Ntypes of items, whose values and weights are given in the two integers arrays v I and w . of size N, and the capacity C for the knapsack. Then, you will implement your solution by writing a program. The capacity C of the knapsack, number of items, i.e. N, the two arrays vI 1 and w 1 are the parameters of the knapsack problem and they should be the inputs of your program. The output of the program should be a txt file that includes the solution to the knapsack problem, i.e. the types of items put in the knapsack, the quantity for each item type and the total value of all the items placed in the knapsack. For an exemplary knapsack problem solution where item 0 (with value 10) is selected 5 times, item 3 (with value 5) is selected 10 times and item 4 (with value 20) is selected 5 times, the output.txt file should have the following format: Quantities of the Items Placed in the Knapsack Item 0: 5 Item 3: 10 Item 4: 5 Total Value: 200

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

1. How can evolutionary theory explain prosocial behaviour?

Answered: 1 week ago