When I call or invoke a function, think of it as creating a local table.
当我调用一个函数时,想象一下它是在这里创建了一个局部表。
Because I'm sort of curious as to, again, which is the right way to think about this, And then, I'm going to just call it.
因为我很好奇,正确模拟股票的应该是哪种分布,然后我会调用它。
And when you call a function, one of the things X that happens is whatever your passing in, for instance, X, ; and if this is A, this thing gets copied into A; so at that moment in time of calling increment, I actually have two copies of the same value in memory but they're referred to by different names.
当你调用一个函数,其中发生的一件事情是,不管你输入什么,比如,或者是A,它把这个东西复制到A中;,调用increment的时候,实际上在内存中,有两个同样的值的内存块,但是它们有不同的名字。
8 Here, it gets a maximum value of 48 and 85 calls.
这里它的最大值是8,函数调用了85次。
If it was already there, I just look it up.
如果是已经计算过的值,我将查询后再调用它。
Here's the way I would call it.
下面是我调用它的方法。
It's only got two things to do, except what it really says is, that the complexity of search 1 is the same as the complexity of b search, b search because that's the call it's doing.
它只有两件事要做,其实实际上是1,它的复杂度和b,search的复杂度是相同的,因为它调用了。
And then I'll call fast max val passing at this extra argument of the memo.
然后我会调用快速maxval函数,而它是基于这个额外变量memo的。
It's calling the old max val.
它调用的是老的max,val函数。
And, again, the rectangle represents your computer's RAM, the bottom represents the part of RAM that we generally call the stack, main conceptually ends up on the bottom of the stack followed foo by its local variables then the function say foo that it calls and on and on and on and up, but there is, in fact, something above all of this and we've seen this picture briefly and that's this thing called the heap.
再次,矩形表示的是计算机内存,底端表示内存的一部分,通常我们把它叫做堆栈,main函数在,堆栈的底端,之后是,它的局部变量,然后是它调用的函数,等等等等,但是那里有,实际上,在这个上面,我们粗略看看这个图画,这个东西叫做堆。
应用推荐