Knapsack problem (Photo credit: Wikipedia) |
Code:-
Sample Output:-
Enter the number of elements : 3
Enter the profit and weights of the elements
Item no : 1
4 6
Item no : 2
1 2
Item no : 3
7 3
Enter the capacity
7
Items in the KnapSack are :
Sl.no weight profit
----------------------------------------
1 2 1
2 3 7
Total profit = 8
0 comments :
Post a Comment