---
title: "Knapsack Problem"
format:
html:
toc: true
number-sections: true
code-line-numbers: true
callout-icon: false
---
[In-class notes](hand_written_notes/Knapsack5.pdf)
## Learning Goals
- Describe the Knapsack Problem
- Develop recurrence for the Knapsack Problem
- Right pseudocode for the Knapsack Problem
- Analyze the runtime of the Knapsack Problem
## The Knapsack Problem
::: {.callout-note title="Problem Definition" appearance="simple"}
**Input:**
- $n$ items where
* $v_i\in \mathbb{N}$ is the value of the $i^\textrm{th}$ item. å
* $w_i\in \mathbb{N}$ is the weight of the $i^\textrm{th}$ item.
- $W\in \mathbb{N}$, the capacity, or maximum allowed weight of the knapsack.
**Output:** $S\subseteq [n]$
* $V(S)=\sum_{i\in S}v_i$ is maximized.
* $W(S)=\sum_{i\in S}w_i