Question: Knapsack Problem. - Your implementation must rely on a dynamic allocation of memory to store the items in the knapsack. HEADERFILE PROVIDED BELOW Our knapsack
Knapsack Problem. - Your implementation must rely on a dynamic allocation of memory to store the items in the knapsack. 
HEADERFILE PROVIDED BELOW


Our knapsack data structure simply stores a set of items (integer values) and their counts. The header file task2/knapsack.h provides the definitions and the prototypes of the functions for our knapsack. Your task is to implement the functions specified in the header file in a new source file called knapsack.c. I have provided detailed comments about the job of each function, its parameters, and its expected output. You are free to implement more helper functions in your source if needed. But any program should be able to use your knapsack functions by just including the existing header file and accessing the compiled version of your knapsack code. Note that your knapsack.c should not contain a main() function. In order to test your knapsack code, you should create a main() function in a separate file (say test_knapsack.c) which tests the functionality of your knapsack code by calling its functions. As discussed above, test_knapsack.c can only include knapsack.h (not knapsack.c ) You can then use gcc to compile and link your source codes to create an executable. Our knapsack data structure simply stores a set of items (integer values) and their counts. The header file task2/knapsack.h provides the definitions and the prototypes of the functions for our knapsack. Your task is to implement the functions specified in the header file in a new source file called knapsack.c. I have provided detailed comments about the job of each function, its parameters, and its expected output. You are free to implement more helper functions in your source if needed. But any program should be able to use your knapsack functions by just including the existing header file and accessing the compiled version of your knapsack code. Note that your knapsack.c should not contain a main() function. In order to test your knapsack code, you should create a main() function in a separate file (say test_knapsack.c) which tests the functionality of your knapsack code by calling its functions. As discussed above, test_knapsack.c can only include knapsack.h (not knapsack.c ) You can then use gcc to compile and link your source codes to create an executable
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
