Skip to content

Commit 1b15781

Browse files
djeadaCopilot
andauthored
Update notes/dynamic_programming.md
Co-authored-by: Copilot <[email protected]>
1 parent 63e90d4 commit 1b15781

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

notes/dynamic_programming.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,27 @@ We build a two-dimensional table $L[0..m][0..n]$ using the above recurrence.
292292

293293
#### Identifying DP Problems
294294

295-
* If the problem asks for the number of *ways* to do something, DP usually works because smaller counts combine into larger ones; without it, counting paths in a grid would require enumerating every route.
296-
* If the task is to find the *minimum* or *maximum* value under constraints, DP is useful because it compares partial solutions; without it, knapsack would require checking every subset of items.
297-
* If the same *inputs* appear again during recursion, DP saves time by storing answers; without it, Fibonacci numbers would be recomputed many times.
298-
* If the solution depends on both the *current step* and *remaining resources* (time, weight, money, length), DP fits naturally; without it, scheduling tasks within a time limit would require brute force.
299-
* If the problem works with *prefixes, substrings, or subsequences*, DP is often a match because these can be built step by step; without it, longest common subsequence would need exponential checking.
300-
* If choices at each step must be explored and combined carefully, DP provides structure; without it, coin change with mixed denominations cannot guarantee the fewest coins.
301-
* If the state space can be stored in a *table or array*, DP is feasible; without this, problems with infinitely many possibilities (like arbitrary real numbers) cannot be handled.
295+
* If the problem asks for the number of *ways* to do something:
296+
* Example: Counting paths in a grid.
297+
* Consequence: Without DP, you would need to enumerate every route.
298+
* If the task is to find the *minimum* or *maximum* value under constraints:
299+
* Example: Knapsack problem.
300+
* Consequence: Without DP, you would need to check every subset of items.
301+
* If the same *inputs* appear again during recursion:
302+
* Example: Fibonacci numbers.
303+
* Consequence: Without DP, Fibonacci numbers would be recomputed many times.
304+
* If the solution depends on both the *current step* and *remaining resources* (time, weight, money, length):
305+
* Example: Scheduling tasks within a time limit.
306+
* Consequence: Without DP, brute force would be required.
307+
* If the problem works with *prefixes, substrings, or subsequences*:
308+
* Example: Longest common subsequence.
309+
* Consequence: Without DP, exponential checking would be needed.
310+
* If choices at each step must be explored and combined carefully:
311+
* Example: Coin change with mixed denominations.
312+
* Consequence: Without DP, you cannot guarantee the fewest coins.
313+
* If the state space can be stored in a *table or array*:
314+
* Example: Problems with discrete states.
315+
* Consequence: Without this, problems with infinitely many possibilities (like arbitrary real numbers) cannot be handled.
302316

303317
#### State Design and Transition
304318

0 commit comments

Comments
 (0)