The Knapsack Problem

From NovaOrdis Knowledge Base
Revision as of 22:09, 1 November 2021 by Ovidiu (talk | contribs) (→‎Overview)
Jump to navigation Jump to search

External

Internal

Overview

The knapsack problem shows up every time there's a budget and we want to use it in the most optimal way possible, as a function of a second dimension. This is a quite fundamental problem.

Problem Defintion

The input is given by n items {1, 2 ... n}. Each item comes with a non-negative value vi and a non-negative and integral size wi.

Additionally, a non-negative integral capacity W is also given.

The output should be a subset S ⊆ {1, 2 ... n} that maximizes the value of all objects of the subset:

 ∑vi
i∈S

so they all "fit" within the capacity W:

 ∑wi ≤ W
i∈S