当前位置:网站首页>Tabulation v.s. Recursion With Memory (Dynamic Programming)
Tabulation v.s. Recursion With Memory (Dynamic Programming)
2022-06-12 01:19:00 【Yangsier】
Question
DP vs Recursion with memorization
I am wondering if that for any recursive function that can be translated into dynamic programming, is it always possible to also simply leave the function in its recursive form and apply a memorise wrapper to it as well? While we have clearly been shown there are many benefits to turning something into dynamic programming, I feel like some functions may be a lot easier to understand if they are in a recursive form and using a memorise function should help keep running costs low.
Such as the example in lecture 17 with seam carving, in my mind it would be considerably easier to understand what a function was doing if it worked backwards from the end point and recursively found the best path to that point, all why keeping running costs low due to a memorise wrapper.
My Answer
In my opinion, the bottom-up method and the top-down with memory (or recursive with memory) are quite similar methods (or they wouldn’t be classified as dynamic programming together).
- They both keep something in a list (maybe dimension higher than 1)
- They both cut off the calculated recursion tree. Make sure recursion runs under polynomial-time.
The difference between them is the way they fulfill the memory space and how they cut the recursion tree.
top-down with memory | bottom-up |
|---|---|
generate data in memory in a passive way | generate data in memory in an active way |
when recursion algorithms visit a node, we store information | when we visit nodes in whatever order we like and then store information |
when visiting a stored node, we call its value from memory | after observing the pattern of whole memory, we go through all nodes without repeatation |
we compute while storing information while cutting redundant trees | we fulfill memory, then we find a way to cut redundant trees, and finally, we compute |
Hope this comparison table can help you with understanding.
(By the way, I think memory decorator is easier to understand and much more to implement too.)
边栏推荐
- Crawler case 05 - parsing websites using XPath
- About MySQL password modification failure
- The annual salary of testers in large factories ranges from 300000 to 8K a month. Roast complained that the salary was too low, but he was ridiculed by netizens?
- Codemirror 2 - highlight only (no editor) - codemirror 2 - highlight only (no editor)
- VM tools fail in VMware? Install VM tools using Ali image source
- 2022-06-11:注意本文件中,graph不是邻接矩阵的含义,而是一个二部图。 在长度为N的邻接矩阵matrix中,所有的点有N个,matrix[i][j]表示点i到点j的距离或者权重, 而在二部
- C language structure - learning 27
- Lambda intermediate operation filter
- 打造Flutter高性能富文本编辑器——渲染篇
- Kill, pkill, killall, next, what I brought to you in the last issue is how to end the process number and rush!
猜你喜欢

Weekly CTF 第一周:神奇的磁带

I'm fired because I can only test basic functions····
![[n32g457] remote monitoring of graffiti cloud based on RT thread and n32g457](/img/c3/5c9970d7e77afce925814d0ecd3b96.jpg)
[n32g457] remote monitoring of graffiti cloud based on RT thread and n32g457

Recursive and non recursive transformation

In depth description of Weibull distribution (1) principle and formula

MS-HGAT: 基于记忆增强序列超图注意力网络的信息扩散预测

LabVIEW Arduino electronic weighing system (project Part-1)

Image retrieval based on cross modal AI model
![[project training] verification notes](/img/bd/fa6111d967da6258bc53d6755cc3a2.png)
[project training] verification notes

Verification code is the natural enemy of automation? Let's see how Ali P7 solved it
随机推荐
Argodb 3.2 of star ring technology was officially released to comprehensively upgrade ease of use, performance and security
A knowledge map (super dry goods, recommended collection!)
System. Commandline option
Image retrieval based on cross modal AI model
Common assertions for JMeter interface testing
2022-06-11: note that in this document, graph is not the meaning of adjacency matrix, but a bipartite graph. In the adjacency matrix with length N, there are n points. Matrix[i][j] represents the dist
一看就懂的JMeter操作流程
jvm: 线程上下文类加载器(TheadContextClassLoader)
写代码复现论文的几点建议!
Lambda创建流
C language multidimensional array and pointer - learning 24
ARP instruction
Lambda intermediate operation filter
王希廷博士:从知识图谱和自然语言生成的角度认识可解释推荐
Lambda termination operation foreach
I worked as a software testing engineer in a large factory and wrote "one day's complete workflow"
中创专利|中国5G标准必要专利达1.8万项,尊重知识产权,共建知识产权强国
About MySQL password modification failure
【项目实训】微信公众号获取用户openid
Nat. Comm. | supercomputing +ai: providing navigation for natural product biosynthesis route planning