If you give me a number and a string, I'm going to concatenate them together, it's really different operations, but nonetheless, it's what it's going to do.
如果给的输入是一个数字和一个字符串,我将会把它们连接在一起,这实在是不正确的操作,但是无论如何,它就是会去这么做。
It's saying, if you give me two numbers, I'll do the right thing.
也就是说,如果你给我两个数字,那么操作是正确的。
And those are two things that you'd like to do with every looping construct you write: you'd like to be able to assure yourself that they will always terminate, and then the second thing you'd like to do, is to assure yourself that it does give you back a reasonable answer.
就是现在我有了能去检查程序,是不是做了正确的操作的能力:,这就是你们在写每个循环程序的时候,都要注意的两个事情:,第一件事情是要确保程序可以终结,第二件你要做的事情,就是要确保程序返回了正确的答案。
If I now say, I'm going to go ahead and change the radius of this, something, my polar form did it right, but what happened to the Cartesian form?
如果我现在说,我要去改变这里的半径,一些这样的操作,我的极坐标形式,进行了正确的改动?
It's going to do the right thing.
一些必要条件的它能做正确的操作。
What is this? This is a wonderful piece of abstraction. It is saying, you don't need to know squat about what's inside the body of this function. You don't have to worry about the parameter names, because they're going to be preserved, you don't need to worry about how I'm doing it, this tells you how you can use this, in order to use it correctly. Of course, I can then close it off, and off we go.
但是这能告诉你一些信息,这是什么?,这是一段完美的抽象,它的意思是你不需要知道,这个函数的内部构造,你不必担心参数是否重名,因为它们已经被预存了,你不需要担心我如何使用它,它告诉了你你该如何操作,从而正确的使用它,当然我也可以把它关掉。
So we're to assume we can get to any piece of data, any instruction in constant time, and the second assumption we're going to make is that the basic primitive steps take constant time, same amount of time to compute. Again, not completely true, but it's a good model, so arithmetic operations, comparisons, things of that sort, we're all going to assume are basically in that in that particular model.
因此如果我们假设在恒定的时间内,我们可以取得任何一块数据,任何一种数据结构的话,我们要做的第二个假设就是,基本的原始操作计算花费的时间是恒定的,这个假设也不是完全正确的,但这个模型其实挺不错的,因此算法操作,比较,这一类的事情,我们在这个特定的模型中都假设是基本的,操作,花费的时间是恒定相同的。
Another way of saying it is, I've actually said, what did I use there, and , It's basically saying there is the first point, there's the second point, add them together and I get that point.
我要去做的是-对不起,再运行一次-好,你可以看到我已经把,这两个点的坐标值加到一块儿了,然后返回了r的值,我会让大家看到我们,实际上得到的是什么,这看起来不错,好,我做了正确的操作。
应用推荐