Dynamic Programming21 sections · 916 units
Open in Course

Intro

The Goal

Some problems ask you to visit all cities, assign all workers, or select from all elements. With nn items, there are 2n2^n possible subsets. Tracking each subset as a state sounds expensive, but for small nn, it's practical.

I'll show you how bitmasks represent subsets as integers. You'll learn to read, write, and iterate over subsets using bit operations. Then you'll apply this to classic problems: Traveling Salesman, Assignment, and Subset Partitioning. By the end, you'll know when bitmask DP (dynamic programming) applies and how to implement it.