implementation of knapsack problem example