Well, the infinity mechanism, and many of you will be familiar with this from mathematics or computer science, is recursion.
这种无限机制是递归的,你们许多人会在数学与计算机科学中,熟悉这个词
This sentence expands to a noun followed by a verb followed by a sentence and there you get recursion.
这个句子就扩展成了,一个名词,后跟一个动词,再接刚才的句子,这样就变成了递归
So, the curious thing about recursion is that pretty much always can you implement this idea of doing the same thing again and again and again but with smaller bytes each time.
可见,递归算法中新奇的一点是,为了实现一个想法,你可以一遍又一遍地做相同的事情,但每次的规模都会有所减小。
And the reason I want to show you this is to notice that the recursion can be doubled.
如果我来写斐波那契数列你可以看看这儿,原因是我想让你看看这部分的递归可以翻倍。
And the idea behind recursion I'm going to describe with a simple example. And then I'm going to show you how we can actually use it.
但是为了解释递归的意义,我想举个简单的例子,我将会给你们展示我们该如何使用它。
- 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.
在这儿就会觉得递归有点迷糊了-,起初,你必须一层一层地,深入到问题中。
And this is obviously a toy example but you could see the use of recursion in everyday life and in everyday use of language.
这只是个小例子,但在日常生活和日常用语中,递归的应用极为广泛
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 this too is where the power of recursion comes in in a programming language.
这也是在编程语言中,对递归很有影响的一点。
Because the algorithm I proposed is going to leverage this idea of recursion which recall was just a piece of jargon we tossed out at the last-- at the end of last week's lecture, last time's lecture recursion really in this context refers to the act of a function calling it's self.
因为我提出的这种算法使用了,递归的思想,这是上周课程的最后,所提出的一个术语,上次的课程中,递归是指,函数的自我调用。
We're going to see variations of this, we're going to see a variation of it called recursion, a little later on, but for now we're just going to talk about how do we do iterations.
我们稍后会去,看它的变量,它的所谓的递归数的变量,但是现在我得先讲讲,怎么来实现迭代。
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循环之类的,那是很呆板的机制。
And that is to introduce the idea of recursion.
去思考问题。
应用推荐