r/programming • • Apr 16 '19

A graphical introduction to dynamic programming

https://medium.com/@avik.das/a-graphical-introduction-to-dynamic-programming-2e981fa7ca2?source=friends_link&sk=37cd14642cf1a83eb0bb33d231442837
55 Upvotes

14 comments sorted by

View all comments

2

u/opiating Apr 17 '19

How does dynamic programming relate to the use of generators i.e. yield

1

u/akdas Apr 17 '19

Dynamic programming is a general technique for creating algorithms, whereas generators a tool you can use to implement algorithms. You can use both together in many ways.

For example, with the Fibonacci numbers I presented in the article, you may generate (yield) individual numbers in the sequence one by one. This would allow someone to consume these numbers sequentially, but to get to that point, you may use dynamic programming to generate the numbers in the first place.