Four rules of recursion
来源:互联网 发布:手机号码采集软件 编辑:程序博客网 时间:2024/05/21 06:22
1. Base cases. You must always have some base cases, which can be solved without recursion.
2. Making progress. For the cases that are to be solved recursively, the recursive call must always be to a case that makes progress toward a base case.
3. Design rule. Assume that all the recursive calls work.
4. Compound interest rule(合成效益法则). Never duplicate work by solving the same instance of a problem in separate recursive calls.
在写递归时,这4个法则需要注意。
关于第4个法则,比如用递归来算斐波那契数列,那么会有大量的重复性工作,会大大影响程序运行效率。
Data Structures and Algorithm Analysis in C
2015.7.11
0 0
- Four rules of recursion
- 数据结构与算法分析:第一章:Finding the kth largest number and The four basic rules of recursion
- Example of Recursion.
- the operation of recursion
- gang of four resources
- summation of four primes
- Four steps of gcc
- Gang Of Four
- Gang of Four
- Four stages of career
- [LeetCode]Power of Four
- 342. Power of Four
- Power of Four-Leetcode
- LeetCode Power of Four
- LeetCode - Power of Four
- 113.Power of Four
- 342. Power of Four
- LeetCode342. Power of Four
- FASTREPORT 预览 编辑页
- DOM文档学习
- 趣味描述之匈牙利算法
- urlrewrite 地址重写
- C语言的字符串输入输出
- Four rules of recursion
- Java跨平台原理
- 关于镜像文件和虚拟光驱
- 机房收费系统——退卡
- vector使用swap释放内存
- UVA529 Addition Chains (迭代+DFS)
- 聊天室螺旋式体系结构设计——思考过程
- Java程序员,你为什么要关注Scala
- SEO优化-伪静态-URLRewrite 详解