码迷,mamicode.com
首页 > 其他好文 > 详细

Recursive functions and algorithms

时间:2014-06-15 22:47:35      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:class   http   ext   com   strong   html   

http://en.wikipedia.org/wiki/Recursion_(computer_science)#Recursive_functions_and_algorithms

A common computer programming tactic is to divide a problem into sub-problems of the same type as the original, solve those sub-problems, and combine the results. This is often referred to as the divide-and-conquer method; when combined with a lookup tablethat stores the results of solving sub-problems (to avoid solving them repeatedly and incurring extra computation time), it can be referred to as dynamic programming or memoization.

A recursive function definition has one or more base cases, meaning input(s) for which the function produces a result trivially(without recurring), and one or more recursive cases, meaning input(s) for which the program recurs (calls itself). For example, the factorial function can be defined recursively by the equations 0! = 1 and, for all n > 0n! = n(n − 1)!. Neither equation by itself constitutes a complete definition; the first is the base case, and the second is the recursive case. Because the base case breaks the chain of recursion, it is sometimes also called the "terminating case".

Recursive functions and algorithms,布布扣,bubuko.com

Recursive functions and algorithms

标签:class   http   ext   com   strong   html   

原文地址:http://www.cnblogs.com/leoshuyi/p/3785374.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!