Add dynamic-programming module: ten classic DP problems, memoization vs tabulation vs space-optimised, call-count and pitfall transcripts (11 tests)

This commit is contained in:
2026-11-09 08:41:01 +00:00
parent 911aef5515
commit cb1b28682f
33 changed files with 1551 additions and 0 deletions
@@ -0,0 +1,12 @@
Fibonacci: how many calls does each approach make?
==================================================
n fib(n) naive calls memo calls table steps
10 55 177 19 9
20 6765 21891 39 19
30 832040 2692537 59 29
40 102334155 331160281 79 39
naive calls = every call the recursion made (counted, not predicted).
memo calls = the same recursion with a notebook: 2n-1 calls, because each F(k) is computed once.
table steps = additions in the bottom-up loop (n-1).