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. Knapsack Problem. - Your implementation must rely on a dynamic allocation ofmemory to store the items in the knapsack. HEADERFILE PROVIDED BELOW OurHEADERFILE PROVIDED BELOW

knapsack data structure simply stores a set of items (integer values) andtheir counts. The header file task2/knapsack.h provides the definitions and the prototypes

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

1 Expert Approved Answer
Step: 1 Unlock 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

Students Have Also Explored These Related Databases Questions!