So let me write that down, it's how much memory do I need to complete a computation.
让我把它写下来,当我计算的时候。
So even within this framework of, given a description of a computation as a set of steps, in the idea that I could build a circuit to do it, let me suggest for you what would be a wonderful circuit to build.
所以即使需要在将计算描述,当成一系列步骤中的一步,这个框架之内,我也完全可以建立一个线路,来完成那个想法,让我为你们假设能建造起,一个多么棒的线路吧。
I only give, I don't know, about 10% or 20% for getting the right number in a computation. I tell my graders, if the student demonstrates minimal acceptable proficiency that student has to get a passing score.
我只是给,我不知道,10%或者20%的随机概率得到合适的数字,我告诉我的学生们,如果有人想证明,最小可接受的熟练,就是学生们得到一个及格的分数。
Then, there's a lot of computation going on to figure out what's the right answer.
将进行大量计算,以找到正确答案。
The mind reflects the workings of the brain just like computation reflects the working of a computer.
心理反映了大脑的活动,就像运算结果反映了计算机的运行一样
Second thing we saw is, that using this as a computation, I can return multiple values.
我们看到的第二件事是把它用作计算,我可以返回多个值。
I've captured it as a computation.
我把它到做计算来用。
Because in doing that, Python would then have a value that it could pass on into some other part of a computation, and if it wasn't what I wanted, I might be a long ways downstream in the computation before I actually hit some result that makes no sense.
因为如果这样做的话,Python会将,输入的值传递到下面的,一些运算中去,如果这个值的类型不是我想要的,我可能会在得到,一个毫无意义的结果之前,经历一个很长时间的,计算过程。
It's going to let us bury away the specifics of something, and treat that computation like a black box. And by black box, I mean, literally behaves like a mysterious little black box.
通过抽象我们可以将一些细节,掩埋起来并将这一段计算当成黑盒,说到黑盒我的意思就是,字面上的像一个神秘的小黑盒。
it's looking first to see am I in the base case, which I'm done. If I'm not I'm just going to reduce this to a smaller computation.
注意这个计算是干什么的,它先判断我是否属于基础事件,这个我已经做过了。
All right? If you run it, you have a sense of the upper bound, about how much time it's going to take to do this computation, so you're not going to get surprised by something showing up.
第一,这样做意味着没有意外了对不对?,你去运行程序,你已经大致知道运行时间的上限了,因此发生任何事情,你都不会吃惊了。
I can check it, so if this was part of some other computation, I want to know, did it find a perfect square or not?
我可以检验它,因此如果这是其它计算的一部分我想知道,它能否找到一个完全平方根呢?
When we talk about space, what we usually refer to is, how much computer memory does it take to complete a computation of a particular size?
我们经常指的是,当我们计算,一个特定大小的问题的时候,要占用计算机的多少内存?
As I said, what we want to do is, we want to count the number of basic steps it takes to compute a computation as a function of input size.
我刚才提到了,我们要建立,一个根据输入大小的方法来计算,一个计算过程需要的时间,建立这个方法需要几步呢?
OK, in a few minutes we're going to start talking then about what is computation, how are we going to start building those tools, but that's what you should take away, that's what you're going to gain out of this course by the time you're done.
好啦,我们会花一点儿时间,谈谈什么是计算,我们如何去建造这些工具,但是这些是你应该,在离开这个课堂时,应该学会的事儿。
And so what I see is that as I run this, I'm doing a lot of redundant computation.
因此我在这里,看到的是随着我的运行,我将会进行很多冗余的计算。
It's the same computation. But this is a nice way of writing it, often called defensive programming.
这跟原来的计算过程没什么不同,但这是写代码的更优秀的一种方式。
The idea of a function is, that I'm going to capture a common pattern of computation.
函数的目的,就是寻找计算的共同模式。
If I look at those two pieces of computation, I can see a pattern there.
我们可以看到这两块的计算过程,是有个模式的。
OK. Today, for the rest of the lecture, we're going to take a break from the topic of algorithms, and computation, and things of the sort. And do something pretty pragmatic.
好,今天剩下的时间里,我们不再讲算法,计算和排序这些话题了,我们会做一些非常实用的事,我们主要的讲讲测试。
And that leads to a lot of redundant computation.
这就导致了累赘计算。
Let me write a function, in fact the literal thing I would do is to say, identify the things that change, give each of them a variable name because I want to refer to them, and then write a function that captures the rest of that computation just with those variable names inside.
让我来写个方法,实际上我的意思是,辨别出变化的东西,然后给它们逐个命名以区分,然后写一个用来计算,这些变量的,包括计算过程的方法。
Second thing we've got to worry about is, what's a basic step? All right, if I bury a whole lot of computation inside of something, I can say, wow, this program, you know, runs in one step. Unfortunately, that one step calls the Oracle at Delphi and gets an answer back. Maybe not quite what you want.
我们需要担心的第二件事情就是,什么该作为一个基本的步骤呢?,如果我把一大堆的计算过程放到里面,我可以说,噢,这个程序你知道的,一步就完成了,不幸的是,这一步可能要靠预言家才能得到答案,这可能跟你想要的结果不太相同吧。
Computing square root. I'm going to capture it in a piece of code, I'm going to be able to refer to it by a name, and I'm going to suppress the details, meaning inside of that computation, you don't need to know what it does. You just need to know, if I give it the right kind of input, it'll give me back an input that satisfies the contract that I set up.
比如计算平方根,我会用一段代码来说明,我将给它命名,并且忽略细节,意思就是在这一段计算过程中,你不用知道它做了什么,你只需知道,如果我进行了正确的输入,它将会给我符合条件的输出。
It sounds like a hifalutin phrase you use when you're trying to persuade a VC to fund you. Right So to answer this, we really have to ask a different question, a related question; so, what's computation?
这听着很像当你试图,让VC语言帮你的时候说的大话,对,所以为了回答这个问题,我们需要提出一个难题,一个有关的问题;,因此,什么是计算相关呢??
应用推荐