Dynamic Programming: The State You Carry
Dynamic programming has a reputation as the hard part of these assessments, and the reputation does candidates a disservice: it makes them look for something clever when the work is almost entirely in one decision made before any code is written. You have already done DP twice in this course. Kadane's recurrence in the windows lesson is a table with one cell, and the tree recurrences of the previous lesson are DP where the order of evaluation is decided for you by the tree. This lesson is the general case, and the reported problems it covers are the friendly kind: count the ways to reach a total, score a two-player game, cover a tree with cameras.
The two questions
Every DP is an answer to two questions, in this order.
The rest of this lesson is for subscribers
Unlock every lesson in Programming for Quantitative Developers, and every other premium course.
Subscribe to continueTest your knowledge
Keep reading Programming for Quantitative Developers
25 lessons in this course, and every other premium course, on one subscription.
- Every lesson in every course, with the worked examples and interactive simulators
- Graded questions on every lesson, with explanations for the wrong answers as well as the right one
- The trainers, timed assessments and brainteaser library that go with them