# Exercises

Practice linear and integer programming.

Let’s solve some continuous and discrete linear optimization problems.

## Exercise 1: Fractional knapsack

The **fractional knapsack** is the continuous version of the knapsack problem. In this version, we can get a fraction of the item. The value would be the same fraction of the item’s value and weight of the same fraction of the weight. For example, consider an item of value $6$ and a weight of $9$kg. If we decide to take one-third of the item, then we get value $\frac{1}{3} * 6 = 2$ from the object, and the weight added to the load will be $\frac{1}{3} * 9 = 3$kg. As in the knapsack problem, the constraint is not to load more than the maximum weight allowed and the goal is to get as much value as possible.

In this exercise, we have to solve the fractional version of the knapsack problem.

Get hands-on with 1200+ tech skills courses.