It could be multiple versions. And we're going to come back throughout the term to think about how to code programs that reflect this.
可能是一种形式也可能是多种形式,我们再回到递归这个术语上来,用它来思考怎样编出。
So this is very similar, this is a kind of recursive thinking we talked about earlier, where we take our problem and we make it smaller we solve a smaller problem, et cetera.
我们则跳过比猜想数小的那个区间,然后我们重复这一过程,跟之前我们讲过的,递归思想非常类似,我们解决问题的时候,先把问题一步步变小,然后解决小问题。
- So this is where recursion gets a little trippy-- certainly initially, and that you have to kind of keep diving deeper, deeper, deeper into the problem.
在这儿就会觉得递归有点迷糊了-,起初,你必须一层一层地,深入到问题中。
This is actually a piece of code that is really easy to think about recursively and is much more difficult to think about in other ways.
这确实是一段用递归思考起来非常容易,而其它方法特别麻烦的代码,这一段代码的意思就是。
All right, I want to show you one last example of using recursion because we're going to come back to this. This is a classic example of using recursion. And that is dating from the 1200s and it is due to Fibonacci.
并且返回答案,我想给你看看递归的最后一个例子,因为我们还要再看一遍,这是一个递归的经典案例,它可以追溯到13世纪。
And you'll find in the end that recursion is a feature of a language, it allows you to map some very obvious concepts like the phonebook tearing in half and half and half and half to actual code without it using some arbitrary human contrived framework like a for loop or a while loop which are much more stilted mechanisms.
最后你会发现递归是某种语言的一种特征,你可以用它将一些非常明显的思想,比如将电话簿划分为一半又一半,映射为实际代码,而不必使用那些人为框架,像for循环,while循环之类的,那是很呆板的机制。
This is another way of doing exponentiation, but this one's a recursive function. All right?
但这是一种递归的方法对不对?,好,让我们看看这种方法?
应用推荐