knapsack algorithm using greedy method