Question: C Programming: KnapSack Problem using dynamic programming: DETAILS: Here is what I have so far: I already have the function to print the max value.
C Programming: KnapSack Problem using dynamic programming:
DETAILS: 
Here is what I have so far: I already have the function to print the max value.
struct node { int weight; int value; char desc[32];//limited to 32 characters, with no spaces int valid; };
struct result { int value; int counts[128]; };
int MaxValue(struct node* items, int itemCount, int capacity) { int best = 0; if (capacity ==0) return best; for(int i = 0; i best) { best = temp; } } } return best; }
____________________________________________________________
All i need help with is tracking the inventory. Printing how many of each item was put in the bag. (: Thats it. I have everything else. Thanks!
your program should read the file knapsack.data from the current directory. This file should contain a set of weight/valueame triples, such as the following: 1 10 mouse 2 25 cellphone 5 40 tablet 7 100 laptop In the above file, there are four items: a mouse with a weight of 1 and value of 10; a cellphone with a weight of 2 and value of 25; and so on. After reading knapsack.data and storing the data in arrays, you should call a function (I called this MaxVal(x) in class) for computing the maximum value that can be loaded into a knapsack with a weight capacity of x. MaxVal(x) works by returning 0 if x
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
