"My friends and I have made a list of things we want to do over the summer. Different places to travel, to get away to, maybe a beach a few hours away.
VOA: special.2010.06.18
So in this case, one of the standard ways to do this, is to use what's called a linked list.
标准的处理方法是使用链表,我接下来也准备这么做。
So do reach out ultimately to your assigned teaching fellow, to me, to the help list, to the forums online.
所以务必联系到你们的研究生助教,到我这,到那个帮助栏,到在线论坛上。
Creating rural jobs is on everyone's to-do list, from the government to the U-N to aid groups.
VOA: standard.2010.03.30
Now this is actually a poor way to do it, because you might say, well, it's just the list.
它以这种形式显示出来了,现在这实际上是一种很差劲的方法,因为你可能会说,好吧。
So, she is interested in how this molecule, gemcitabine, inhibits an enzyme. So, to do those studies, she needs to know a lot of the stuff on this list.
她对这个分子,二氟脱氧胞嘧啶核苷怎么抑制酶很感兴趣,要做这些研究。
Finally, they got Harry Hamlin to do it, who was kind of a B-list sort of guy.
最后他们找了Harry,Hamlin来演,他是一个二线演员。
But what you should be able to do is take a look at a list of answers for what we're saying z effective might be, and determining which ones are possible versus which ones are not possible.
但是你们应该能够做到的,是看一下这个可能的,有效电荷量的答案列表,并且确定哪些是可能的,哪些是不可能的。
So I'm first going to look for something that's not in the list, I'm going to see, is minus 1 in this list, so it's going to be at the far end, and if I do that in the basic case, bam.
如果我试试第一种最基本的方法,噢,一下就完成了对不对?,因为这种方法查了下第一个元素,然后发现目标数比较下,因为目标数小于第一个元素。
And what does that say? It says, let's assume I want to do k searches of a list. OK.
如果我们假定要在列表中做k次搜索,在线性的情况下,假定是一个未排序的情况。
OK? So the example I'm going to do, I'm going to search a sorted list.
来搜索目标元素,好,翻到课堂材料的第二页。
So an easy way to do this would be to say, let's just represent them as a list.
一个简单的方法就是,让我们用数组的形式。
So halfway is the right thing to do, because at each step, I'm guaranteed to throw away at least half the list. Right? And that's nice.
一半以上的元素,对不对?,这很棒,好,大家猜猜这个算法的增长率是多少?,为什么?太对了。
So it's going to look at the rest of the list, walking along, and what does it do?
所以它会查看列表剩下部分,遍历它们,那它要做什么呢?
The easy thing to do would be the following: start at the front end of the list, check the first element. If it's the thing I'm looking for, I'm done. It's there. If not, move on to the next element. And keep doing that.
从数组的第一个元素开始:,如果这是目标元素那么结束,如果不是的话就继续比较下面的元素,并一直这么比较下去,但如果,在某一点我发现我要寻找的数字。
Are you sure you didn't want to do for i in range of list, rather than for i in list?
你真的打算这么做吗?你确定你不是,想在链表范围内定义i而不是定义链表i?
So let me expand on that very slightly, and again we did this last time but I want to do one more time. I have to be careful about how I'm actually implementing a 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?
我只能做线性搜索了,一次遍历一遍列表,一个一个比较,但如果我想要,那怎样得到有序的列表呢?,现在的一个问题是,我们排序之前?
Takes in a list. What does it say to do?
这段代码要做什么?
Here's the problem. How do I get to the nth- er, the k'th element in the list, in this case?
如何找到第n个元素呢-,在这里,如何找到第k个元素呢?
You try to design actually I'm going to come back to that in a second. It's like you're trying to use a hash function that spread things out pretty evenly. But the places you store into in those lists may have to themselves have a small list in there, and when you go to check something, you may have to do a linear search through the elements in that list.
你尝试着去设计,实际上过会儿我会回头讲解这个问题,类似于你需要用一个哈希函数,非常平均的将物体分发出去,但是在列表中你数据,映射到的地方可能会有自己的一小段列表,当你回头查找数据的时候,你可能需要在那一小段列表中做线性查找。
So to just preface what we're going to do next time, what would happen if I wanted to do sort, and rather than in sorting the entire list at once, I broke it into pieces, and sorted the pieces, and then just figured out a very efficient way to bring those two pieces and merge them back together again?
所以为了引导下一次,我们要讲的内容,如果我想做排序,而且不是一次吧整个列表排完,会发生什么,我把它拆成小的列表,然后把各个小列表排序,接着用高效的方法再把小的列表?
LS And what very often happens if you do an LS in your account, to list your files, there's a whole lot of stuff in here at the moment -- and I don't have it here - but what you'll often see -- I'll just fake this demo -- is a file called core.
经常发生的是,如果你用你的账号做一个,来列出你的文件,此刻这里有一大堆元素,-它不在这里,但你们将经常看到--我将篡改这个演示-,是一个叫做core的文件。
So I'm going to go over here, and I'm going to type test search-- I can type and if you look at your handout, it's just a sequence of tests that I'm going to do OK. So initially, I'm going to set up the list to be the first million integers.
大家可以看看你们的课堂材料,那儿有一些我要做的实验,好,一开始我先去建立个,含有一百万个integer的数组,对,这有点儿简单,但是这给我提供了这样一个有序的数组。
To get any location in memory, to get to any value of the list, I simply have to say which element do I want to get, I know that these things are stored in a particular size multiply that index by 4, add it to start, and then it's in a constant amount of time I can go to that location and get out the cell.
取得列表中的任何一个值,简单说来,想要取得列表中的任何元素,我知道这些元素存在特定的大小中,把下标乘以4,加到start上,然后定位到内存单元,并取出值就是固定的时间了,好的,如果元素以固定大小存储。
应用推荐