Having done that, it goes back up and picks the second sub-list, which came from there. It's a down to base case, merges it.
就是从那里得来的,完成这些后,回到上一步。
So finger-pointing at the start of each list, 6 is indeed less than 8 so I'm gonna write it down first.
手指指向列表的开始,6肯定比,8小,我先把它写下来。
And if I'm walking down the list, this is probably order of the length of the list s because I'm looking at each element once.
这可能大概就是数组的长度,因为我会遍历数组中的每个元素一次,现在你可能会想,等等,数组已经排好序了。
There are all kinds of things that it might be very useful ; for you to know as an inhabitant of Western civilization; and the New Testament,you might find out, would rank kind of down on the list of those kinds of things.
作为西方文明的一分子,有很多有用的东西可以学;,而新约,你会发现,与这些东西相比,排名比较靠后。
If you can't hold your job down, you can't get the money Ultimately, most of the negative things on that list were instrumentally bad.
无法工作就赚不到钱,最终名单上多数消极的东西,都归结为坏的利用价值。
Put yourself down on the wait list if you don't get into the section you want.
如果你想换个小组,请在等候名录里预约
We're going to go down the whole list.
我们会顺全部的名单。
Things like heart disease and cancer are down the list.
像心脏病和癌症占的比例很小
One of them was Bear Stearns so I don't know whether they're still on the list maybe they are maybe they're not; we might be down to nineteen.
其中一家是贝尔斯登,所以我不知道,它是否还在那名单上,也许在,也许不在了;,所以我们也许可以说名单上有十九家。
Now, you can bet when these folks came and consulted the priest and could you please put us down on the list, we want to consult the oracle, the priest said sure have a beer, let's talk about your hometown, what's going on out there.
你能想到,当人们到此请示神谕,会对祭司说,您能把我们的名字写在表里吗,我们想询问神谕,祭司说有啤酒就行,我们先说说你的家乡,那儿发生了什么事
Ignore this one here 'cause this is when I was just writing down the original list of size 1.
暂且忽略这个,因为它是大小为1的列表中的元素,我只是把它写下来而已。
OK. So, soon as I get down to a list that has no more than two elements in it, I'm done.
不超过2个元素的列表,那就结束了,注意,这里是小于等于。
Well, notice again, on each level of the tree, when I actually do the merging, so this remember, is when I wrote down just the numbers when I bottomed out with the list of size 1.
请注意,在这棵树中的每一层,我真正做合并时,就将每个大小为1的列表中的,数字写下来。
First, it's pointing to the beginning of the list, which initially might be down here at but after a while, might be part way through. And to that, I simply add a halfway point, and then I check.
列表中间的一个部分了,然后我求出列表的中值点,然后看看该点的值是不是等于目标值,如果是的话就完成了,如果不是的话,如果中位值大于我要找的目标值。
We actually threw half of the list away and we kept dividing it down, until ultimately we got something of size one to search.
我们实际上将另一半的列表给抛弃了,我们接着不断的如此分解下去,直接最终我们搜索到了唯一的一个元素。
I just go down the list selecting the smallest person at a time and then I repeat, repeat, repeat but when we actually did out the math or kind of reason through it, the running time, the asymptotic running time of bub-- of Selection Sort was also what?
只需要遍历列表,每次找出最小的元素,然后重复上述步骤,但从数学角度看,选择排序的时间复杂度,又是多少呢?
How do I figure that out? Well I'm looping down the list, right? I'm walking down the list.
怎么算出来的呢?我在循环遍,历这个列表对吧?那要遍历这个列表。
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.
等等,随着移动,剩下的部分越来越小,并不是初始那么长了,如果你算一算,或者你这么想,你考虑更一般的情况,平均下来至少是列表的长度。
Well let's see. My fall back is, I could just do linear search, walk down the list one at a time, just comparing those things. OK. So that's sort of my base. But what if I wanted, you know, how do I want to get to that sorted list? All right?
我只能做线性搜索了,一次遍历一遍列表,一个一个比较,但如果我想要,那怎样得到有序的列表呢?,现在的一个问题是,我们排序之前?
So let me move down the list or put this cup back.
在列表中继续向下移,将这个杯子放回去。
Simply walk down that list.
执行一个直线序列的程序。
I'm walking down the list.
算法遍历了一遍数组。
At each stage, no matter which branch, here or here, I take, I'm cutting down the length of the list that I'm searching in half. All right?
选的是这里还是那里,我总是把列表分成两半,对吧?,所以如果我处理一个长度为n的列表?
I'll let you just grok it but you can see it's basically doing what I did over there. Setting up two indices for the two sub-list,it's just walking down, finding the smallest element, putting it into a new list. When it gets to the end of one of the lists, it skips to the next part, and only one of these two pieces will get called because only one of them is going to have things leftovers.
你们可以大体的浏览一下,但是它们基本就是我在那里所做的事情,为两个子列表设置了两个指针,指针顺着列表走下去,找到最小的元素,把它放入到一个新的列表中去,当它走到一个列表的尾部时,它会跳到下部分去,两部分中只有一个会被执行,因为只有一个会有元素剩余。
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个元素的方法,是关于数组的长度呈线性复杂度的,这回增加算法的复杂度。
It's going to let j run over the length of the list all right, so it's going to start at some point to move down, and then it's going to let i run over range, that's just one smaller, and what's it doing there?
就在这里,会做什么呢?,我们让j遍历这个列表,好的,它要从某一定开始移动,然后让i也跑遍整个范围,就是比之要小一,会发生什么?
应用推荐