Knapsack Algorithm Time Complexity