notesonly.in

One notebook for every subject — open it anywhere.

Log in

Dynamic programming

Design and Analysis of Algorithms · Engineering

Study notes

Fibonacci fib(5): naive recursion recomputes fib(3) twice, fib(2) three times: O(2^n). Memoization stores each result: fib(3) computed once, reused. Tabulation fills dp[0..5] = [0,1,1,2,3,5] iteratively: O(n) time, O(n) space, or O(1) with two variables.

← Back to topics for Engineering