Saturday, June 27, 2015

C Code for Knapsack Problem using Dynamic Programming

Knapsack problem
Knapsack problem (Photo credit: Wikipedia)
Knapsack Problem using Dynamic Programming.

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

Follow Me!

Blog Archive

Followers

Visitor Map