Question: You are asked to implement the 0 / 1 Knapsack Problem using the ARM Cortex MO + architecture. In this problem, each item has a
You are asked to implement the Knapsack Problem using the ARM Cortex MO architecture. In this problem, each item has a weight W and a profit P Our knapsack has a limited weight capacity W The objective is to maximize the profit without exceeding the weight capacity of the knapsack.
a Points You are asked to implement the knapsack problem recursively as given below.
#define WCapacity
#define SIZE
int profit;
int weight;
int maxint a int b
return ab a : b;
int knapSackint W int n
if n w
return ;
if weightn w
return knapSackW n ;
else
return maxknapSackw n
profitn knapSackW weightn n ;
void main
int value knapSackwCapacity, SIZE;
while;
b Points You are asked to implement the knapsack problem iteratively as given below.
#define wCapacity
#define SIZE
int profit;
int weight;
int dpwCapacity;
int maxint a int b
return ab a : b;
int knapSackint W int n
for int i ; i n ; i
for int w w; w ; w
if weighti w
dpw maxdpw
dpw weighti profiti ;
return dpW;
void main
int value knapSackwCapacity, SIZE;
while;
Constraints:
cdot Your main function name or label must be main".
Your code should include a comment for each line. Otherwise, points will be deducted.
The program must be implemented with Arm Cortex M assembly language.
Your assembly source file is expected to work with Keil mu Vision IDE v
Default configuration must be sufficient to run your programs. If your program expects any different configuration parameter, please write this at the top of the code in comment lines.
If your program does not run with Keil mu Vision IDE you will get zero point from this question.
At the end of the program, ensure that R stores the value variable from the main function, R stores the starting address of the profit array, R stores the starting address of the weight array, and R stores the address of the dp array if available
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
