锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久国产精品一国产精品金尊,久久中文字幕一区二区,久久精品中文字幕有码http://www.shnenglu.com/uglystone/category/4136.htmlprograming is a pleasure!zh-cnFri, 23 May 2008 03:09:09 GMTFri, 23 May 2008 03:09:09 GMT60Thinking recursivelyhttp://www.shnenglu.com/uglystone/archive/2008/03/16/44620.html涓戠煶涓戠煶Sun, 16 Mar 2008 10:54:00 GMThttp://www.shnenglu.com/uglystone/archive/2008/03/16/44620.htmlhttp://www.shnenglu.com/uglystone/comments/44620.htmlhttp://www.shnenglu.com/uglystone/archive/2008/03/16/44620.html#Feedback0http://www.shnenglu.com/uglystone/comments/commentRss/44620.htmlhttp://www.shnenglu.com/uglystone/services/trackbacks/44620.htmlFirst,Let's know the principle: Recursive leap of faith- When you try to understand a recursive program,you must be able to put the underlying details aside and focus instead on a single level of the operation. At that level,you are allowed to assume that any recursive call automatically gets the right answer as long as the arguments to that call are simpler than the original arguments in some respect.The psychological strategy-assuming that any simpler recursive call will work correctly-is called the recursive leap of faith! The idea may be difficult to newers! Take an example for it: We all know the Fibonacci function: F(n)=F(n-1)+F(n-2) Recursive implementation of the Fibonacci funtion:
int Fib(int n){ if (n<=1) return n; else return Fib(n-1)+Fib(n-2); }
if n is 5,Fib(5) is computed by the sum of Fib(4) and Fib(3). Applying the faith,you can assume that the program correctly computes each of these values,without going through all the steps that Fib(4) and Fib(3) is computed!