I have seen many solutions which solves the Knapsack problem in java using recursion; I'm trying to convert the solution into non-recursive function which probably uses "Stack" or any other optimal solution. I also don't have a value array and I just want to fit the weights into total weight capacity.
For e,g, I have weight input as 60,50, 40,10,30 and the W (capacity) is 180.
Sample KnapSack (with value array); but I don't need value array in my solution: I have seen many solutions which solves the Knapsack problem in java using recursion; I'm trying to convert the solution into non-recursive function which probably uses "Stack" or any other optimal solution. I also don't have a value array and I just want to fit the weights into total weight capacity.
For e,g, I have weight input as 60,50, 40,10,30 and the W (capacity) is 180.