...

/

Introduction to Unbounded Knapsack

Introduction to Unbounded Knapsack

Let's get introduced to the Unbounded Knapsack pattern.

Overview

A knapsack is defined as a bag carried by hikers or soldiers for carrying food, clothes, and other belongings. The Knapsack problem, as the name suggests, is the problem faced by a person who has a knapsack with a limited capacity and wants to carry the valuable important items. In other words, we are given NN items, each having a specific weight and a value, and a knapsack with a maximum capacity. Our job is to put as many items as possible in the knapsack such that the cumulative weight of the items doesn't exceed the knapsack's capacity, and the cumulative value of the items in the knapsack is maximized.

In this pattern, we will be discussing 5 problems related to this pattern. The following diagram shows an overview of this pattern.

Problems explored in Unbounded Knapsack pattern

The Unbounded Knapsack is a special case of the Knapsack problem where there's no limit on the number of instances of each kind of item in the knapsack. The unbounded knapsack is different from 0/1 Knapsack in a way that we are allowed to use multiple samples of an item. However, in the Unbounded Knapsack too, we can't take fractions of an item. We either have to take the complete item or leave it.

Mathematically, we can understand it as: Given nn items, each with a value viv_i ...