Solving the subsets problem with dynamic programming

preview_player
Показать описание
In this video I demonstrate dynamic programming by using it to solve a math problem: how many subsets of {1,…,2000} have a sum divisible by 5?

Along the way we'll talk about phrasing a problem as a recurrence and using optimization techniques like memoization or solving the subproblem first to get an efficient runtime for the algorithm.

Рекомендации по теме
Комментарии
Автор

Nice video
Does python have tail-recursion optimization with trampolining ? If not, the space complexity of the naive algorithm should include the maximum stack size which is O(n) since it will recur to a max depth of n. (Since you had to increase the max recursion depth by hand in the memoization algorithm, I assume TRO is not in effect here)

davidstigant
Автор

I believe there is not enough algorithmic cohesion so solve the subsets so they can be used in SD effectively

SuperMarsovec