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.
如果我试试第一种最基本的方法,噢,一下就完成了对不对?,因为这种方法查了下第一个元素,然后发现目标数比较下,因为目标数小于第一个元素。
It's very chic. It's very beautiful, and it's very... if you are on a list, you're in.
很时髦,很美,很……如果你榜上有名,就请进,
It's going to take this list and add to it something else.
这个代码有什么作用呢?,我将会把一些东西加到这个数组里面去。
Who, in other words, ? is not present in Machiavelli's list of great prophets that one should imitate?
换句话说,谁未名列马奇亚维利的伟大先知名单,即那些该被仿效的伟人?
It's a list of the contents of the knapsack of a soldier during the Vietnam War, just a list of the contents.
故事讲述了一个越战士兵,背包里的东西,只是一系列东西而已。
I think this is as good list so let's go and think about what might be a little bit more challenging.
我想上面这些都是很好的例子,接下来我们思考一些更有挑战的问题
And that's really a placeholder for the comma-separated list of values that I put after those quotes.
这其中还有一个逗号分开的有值的占位符,我把它放到了引号之后。
That's why Humbert can be instantly delighted in the list of names.
这就是为什么亨伯特一看到名单就觉得有趣。
It's a list of what you have to know about a system right now.
它包含系统当前的全部必要信息
I put on the reading list The New Yorker article that's out right now.
在阅读材料上有篇最近《纽约客》上的文章
If I look for, say, minus 1, you might go, gee, wait a minute, if I was just doing linear search, I would've known right away that minus one wasn't in this list, because it's sorted and it's smaller than the first elements.
如果我要查找-1,你可能要怒了,呵呵,等一等,如果我用的是线性查找,我不会知道-1不在这个列表中,但是列表是排好序的,1又比第一个元素小。
So in this case, one of the standard ways to do this, is to use what's called a linked list.
标准的处理方法是使用链表,我接下来也准备这么做。
Yeah, it's kind of simple, but it gives me an ordered list of these things, And let's run it. OK.
让我们来运行运行吧,好,我会先去搜索一些数组中没有的元素,让我来试试,看-1在不在这个数组里。
And I want to show you a little bit more detail of that, so let's create a simple little list here.
我还想给你们再讲详细些,那让我们来创建一个简单的列表吧。
In fact it gives me back, now I hate this, it's actually a list it's not a tuple. But for now think of it as giving you back an explicit version of that representation of all those elements.
它实际上是一个数组而不是一个元组,但是现在你们可以把它认为,是明确的这些,元素的一个表示,你会在接下来的一些课程中看到。
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.
列表中间的一个部分了,然后我求出列表的中值点,然后看看该点的值是不是等于目标值,如果是的话就完成了,如果不是的话,如果中位值大于我要找的目标值。
应用推荐