Small knapsack
His backpack can only hold 50KG of weight (He’s superman). A robber has broken into a jewellery store and wants to steal precious jewellery. The Knapsack Problem is where you have a “bag” that can hold a limited number of items, given that you have a set of items to choose from each with individual “values”, how can you maximize filling your bag with only the most valuable items.
#SMALL KNAPSACK HOW TO#
One of the biggest issues I found with looking for an algorithm in C# to do this, is very rarely did they ever explain how the code worked, or even a thorough explanation on how to use it. One such algo is the “Knapsack Problem”, also sometimes known as the “Rucksack Problem”. But every now and again I come across an algorithm that I think “How have I not heard of this before?”. Let’s be honest, unless you are going for a job interview it’s rare you use these anyway – especially in programming business systems.
While that means I can chew someone’s ear off about the latest feature in C# 8, it also means that I missed out on plenty of “Data Structure/Algorithm” style programming problems. I skipped out on University/College in my earlier years and instead opted to fully self teach myself programming.