IT lexicon Programming Dynamic programming (DP)

Dynamic programming (DP)

Programming På svenska → Updated: 2026-05-23

Optimisation technique: solve recursive subproblems once and cache the results instead of recomputing. Richard Bellman (1950s) — "dynamic" was just to sound impressive to RAND managers.

Two flavours: top-down (recursion + memoization) and bottom-up (iterative table filling). Classic problems: Fibonacci, Longest Common Subsequence, knapsack, edit distance, matrix chain multiplication.

DP works when the problem has optimal substructure (the big solution is built from small ones) and overlapping subproblems (the same subproblem appears repeatedly). Competitor: divide-and-conquer (no overlap), greedy.

← Back to the lexicon