Lab 7-1
Lab 7-1
its
time complexity
#include <stdio.h>
#include <stdlib.h>
return dp[n][W];
}
int main() {
int n, W;
return 0;
}
Output
Enter the number of items: 4
Enter the knapsack capacity: 50
Enter value and weight for item 1: 60 10
Enter value and weight for item 2: 100 20
Enter value and weight for item 3: 120 30
Enter value and weight for item 4: 80 40
Maximum value in Knapsack = 220
Time Complexity = O(4*50)