I have N amount of items, and each item has a weight and a value. I need to fit as many items as I can into a backpack, however they cannot exceed a weight of K. And I need to get the highest amount of value into the backpack without going over weight of K. And I can only use each item once.
This problem is an algorithmic problem, and while it is more related to computer science, I have a question about it that I thought would be best to ask here.
If I divide the value by the weight I get a ratio and call it X. I would then proceed to try and add the highest possible values to each other, without exceeding the weight limit. Would doing this allow me to find the highest possible value and the items that go in it everysingle time, or is this just a greedy solution that would only work part of the time?