Overlapping subproblems

Ever calculated a huge Fibonacci sequence by hand?

Image: Sora / OpenAI, Public domain, via Wikimedia Commons

Overlapping subproblems

Ever calculated a huge Fibonacci sequence by hand?

Imagine you're trying to figure out the 10th number in the Fibonacci sequence, but you keep recalculating the 8th and 9th numbers every time.

You'd waste a lot of time repeating calculations instead of remembering past results.

Example

To find F(10), you'd repeatedly calculate F(8) and F(9), even though you've already done it for F(8) to get F(9).

Remember this

Dynamic programming remembers past results to avoid redundant calculations.

Related concepts

Swipe through 100 ML concepts daily

Open Pocket Polymath