Notice what it says. I'm going to pass in 1 a string, call it s, binds it locally, and it says the following.
然后看接下来的内容,接下来说的是如果这个字符串的长度等于,那么我就成功了。
So it's certainly at least linear in the length of the list. For each starting point, what do I do?
它至少是线性的计算列表的长度,每次到了循环开始的点?
So, when we think about a bond length, this is going to be the length of our bond here, that makes sense because it's going to want to be at that distance that minimizes the energy.
因此,当我们考虑一个键的长度的时候,这就应该是我们的键长,这是合理的,因为体系会在核间距达到这一距离时,能量到达最小值。
The force, as this weight drops is constant, mgh and so the work is just going to be m g h, h where this is h.
当重物掉落时候的力是恒定的,因此做功就是,这段长度是。
Now, of course, we've got to have units and the units for lengths are going to be meters.
当然,这里还得有单位,长度的单位是"米"
And if you don't put a point but just put a number, this specifies the width of space that will be used by the number you're inserting there.
如果你不用点而只用数字,这个指定的长度是由,你插入的数字决定的。
So if I had drawn that better it would look as if this was half of this distance, but I didn't draw it well.
如果我画得准确的话,这段应该是整段长度的一半,不过我没画好
By regular rate we mean that the amount of time that each chord holds is exactly the same; every chord holds for the same length of time.
如果变化频率规则,那么和声中每个和弦持续的时间长度是完全相同的;,每个和弦都持续同样长的时间。
So we can start. This distance here is r naught.
所以我们开始。这里的长度是r圈。
Still quadratic, right? I'm looking for the worst case behavior, it's still quadratic, it's quadratic in the length of the list, so I'm sort of stuck with that.
还是平方,对吧,我在寻找最坏的情况,它还是平方,它是列表长度的平方,我对此有点无奈了。
So when I do the analysis, I want to think about what am I doing here, am I capturing all the pieces of it? Here, the two variables that matter are what's the length of the list, and how many times I'm going to search it?
这里,要关注的,两个变量是列表,的长度以及我要搜索的次数,这种情况下,这个算法赢了?
And I have this, to write it out, this is order the length of the list squared, OK?
我得写下来,这是把列表的长度平方,对么?
It's always good when we're looking for a wavelength that our answer is in a unit of length, that's a good sign already.
当我们计算波长时,如果答案是一个长度单位,那就是一个好的迹象。
As I keep moving down, that part gets smaller, it's not always the initial length of the list, and you're right. But if you do the sums, or if you want to think of it this way, if you think about this more generally, it's always on average at least the length of the list.
等等,随着移动,剩下的部分越来越小,并不是初始那么长了,如果你算一算,或者你这么想,你考虑更一般的情况,平均下来至少是列表的长度。
A magnitude is how long this guy is and direction is at what angle it is.
大小是指它的长度,而方向是指它与坐标轴的夹角
Even though there's four bytes the length of the string is consistent with what a human being would interpret as the length 3 of the string which is 3.
即使那里有4个字节,字符串的长度,与我们所认为的长度是一致的,字符串的长度是。
And the answer has to do with ratios and string sizes and lengths of pipe and things like that, but generally speaking, pitches that are right next to each other--very close to each other--are dissonant.
答案和比率以及弦乐器的尺寸和管乐器的长度等有关,但是总的说来,音调是相关联的,非常近。
You may notice that it's always printing out the same number of digits.
显示同样长度的数字,这是怎么回事儿?
The second question I want to ask is what's the base case? When do I get down to a problem that's small enough that it's basically trivial to solve? Here it was lists of size one. I could have stopped at lists of size two right. That's an easy comparison.
第二个问题是什么是基础条件?,我要将问题分解到何时才使得问题,小到可以解决的基本问题?,这里是当列表的长度为1有时候,我也可以在长度为2的时候停止分解,那是一个非常简单的对比。
It says if I want to get the length of a segment, going to pass in that instance, it says from that instance, get the start point, that's the thing I just found.
它的意思是如果我想要,得到一个线段的长度,首先要把这个实例传进来,然后对于这个实例,从开始点,取得x坐标,然后通过同样的操作。
So this is a - c over b and this is a - c over 2b so this distance and this distance are meant to be the same.
这点是,/b,这点是,/2b,这两段长度应该是相等的
i It takes i, which is in some sense 1 the length of those vectors, minus 1, because of the way Python works.
还有i,某种意义上,是那些向量的长度减,减1由于Python的工作方式。
Yeah. Log. It's a good think, but why do you think it's log? Ah-ha. It's not a bad instinct, the length is getting shorter each time, but what's one of the characteristics of a log algorithm? It drops in half each time.
对了,对数,这是个好想法,但是你们为什么认为是对数呢?,啊哈,这样的本能不错,每次长度都会缩小些,但是对数算法的特性是什么。
I've got to count my way down, which means that the access would be linear in the length of the list to find the i'th element of the list, and that's going to increase the complexity.
的位置并去访问,然后继续下去,也就意味着,找到数组中的第i个元素的方法,是关于数组的长度呈线性复杂度的,这回增加算法的复杂度。
Well, this question mark becomes an O, this question mark becomes an O, and then the loop terminates 0 1 2 because it's iterating from zero to N so that's zero, 1, 2 and the length of the string is 3 so the loop terminates, but I remember that I needed to have this special sentinel value so I'm just going to put it there manually.
嗯,这个问号变成了,这个问号变成了0,然后循环结束了,以为迭代从0到N,那就是,字符串的长度是3,然后循环就结束了,但是我记得我需要这个特殊的标记值,所以需要手动的加上它。
Here's the first list of size one.
这是第一个长度为一的列表。
There's the second list of size one.
那是第二个长度为一的列表。
That's a new unit of length.
那是一个新的长度单位
It's not true, by the way, of all programming languages. In fact, Professor Guttag already talked about that, in some languages lists take a time linear with the length to get to it.
顺便说一句这在大部分,编程语言中做不到,实际上Guttag教授已经说过这一点了,在一些语言中取得数组,要花费时间是线性长度的。
Down here, I've just got two things to merge, and then I've got things of size two to merge and then things of size four to merge. But notice a trade off. I have n operations if you like down there of size one.
但是n的大小是不同的,是吗?在这里我们只要合并两个元素,然后是合并长度为2的列表,接下来是合并长度为4的列表,但是观察一下之间的权衡关系。
应用推荐