They submit their data about their people, their users to us, so Baidu users can easily find information related to that.
校内网将用户数据提交给我们,这样,百度的用户就能够轻松,搜索到相关信息。
Yeah, it's kind of simple, but it gives me an ordered list of these things, And let's run it. OK.
让我们来运行运行吧,好,我会先去搜索一些数组中没有的元素,让我来试试,看-1在不在这个数组里。
And we've been working with them What I will call it prototype; we have not yet done a complete project. But I wanted to show you some pieces of this on slides. So one of the things we've done is create a searchable archive.
我们与他们合作,我称之为草案,我们还没有完成一个完整的项目,但我想给你们看一些幻灯片,我们做的其中一件事就是,创建一个可搜索的档案馆。
So, with that said, we like to Google ourselves sometimes FlyBy and so we discovered that FlyBy last night mentioned CS50 among some other courses in its last minute shopping list.
如此说来,我们有时候会喜欢用Google搜索,然后我们发现昨晚在CS50的其他课程上提到的,在最后一分钟的购物清单里。
If it was an unordered list, we were basically stuck with linear search. Got to walk through the whole list to see if the thing is there.
如果是一个未排序的列表,基本上我们就只能使用线性搜索了,通过遍历整个列表来查看。
We did that, we came up with very good Chinese search engine technology, and we signed up a lot of the Chinese portals in a very short period of time.
我们开发了,很好的中文搜索引擎技术,并在短期内,和许多门户网站公司,签了合约。
Then we really focused on developing the best Chinese search technology and dominate the market.
之后,我们致力于开发中国最好的搜索技术,并掌控市场。
If we could do sort, then we saw, if we amortized the cost, that searching is a lot more efficient if we're searching a sorted list.
如果我们可以做排序,然后我们可以看到,如果我们分摊开支,在有序列表中搜索将会变得更高效。
We came up with this idea that we open up the interface so that people who owns the data, who owns the content, can submit it to us and we will integrate into our search results.
于是我们有了一个想法,开放一个接口,让拥有数据,以及容量的人,能够将其提交给我们,然后整合到搜索结果中。
And the basic idea was that we had some sort of a line and we knew the answer was somewhere between this point and this point.
去学习的二分搜索是有联系的,这种方法的基础思想,是我们有一个线性的序集,我们也明白答案在其中的某一段区间。
And what does that say? It says, let's assume I want to do k searches of a list. OK.
如果我们假定要在列表中做k次搜索,在线性的情况下,假定是一个未排序的情况。
And then we figured that what we're really good at was Chinese search.
之后我们发现,中文搜索才是公司的王牌。
OK. So if I look at this code, first of all I'm calling search, it just has one call, so looks like search is constant, except I don't know what happens inside of b search. So I've got to look at b search.
首先调用一下搜索,就一步调用,看起来搜索是固定的,除非我不知道二分搜索的原理,那我们来看看二分搜索吧,所以让我们看看,第一行打印出来的内容。
We actually threw half of the list away and we kept dividing it down, until ultimately we got something of size one to search.
我们实际上将另一半的列表给抛弃了,我们接着不断的如此分解下去,直接最终我们搜索到了唯一的一个元素。
And you can see it wrapping its way down, cutting in half at each time until it gets there, but it takes a while to find. All right.
但是这也花了一点时间来搜索,好,让我们看看100万,或者1000万是不是在数组里。
We've already spent a fair amount of time this semester talking about searches.
我们这个学期已经花了,很多时间来讲搜索和搜索算法了。
We're going to call binary search, it's going to take the list to search and the element, but it's also going to say, here's the first part of the list, and there's the last part of the list, Well, it checks to see, is it bigger than two?
我们将要调用这个二分查找,它将会在列表里面搜索元素,假定这里是,列表的第一个元素,那里是列表的最后一个元素,代码内部到底做了什么?
I remind you, I know you're not really listening to me, but that's OK. I reminded you at the beginning of the lecture, I said, let's assume we have a sorted list, and then let's go search it.
没关系,我告诉过你在课程的开始,我们假设这是一个排好序的列表,然后才进行的搜索,那实际上有序列表从哪里来的呢?
We really, really focused on Chinese search.
我们没有想那么多,只是专注于开发中文搜索。
So, here's the question.
我们搜索前是否应该排序呢?
If we can sort things, you know, we get this n log n behavior, and we got a n log n behavior overall. But can we actually do better in terms of searching.
如果我们可以排序,如你所知,我们有n,log,n级别的算法,并且我有一个整体的n,log,n级别的算法,但是我们在搜索方面可以做的更好吗?
I could still do the linear case, which is order n or I could say, look, take the list, let's sort it and then search it. But in that case we said well to sort it was going to take n log n time, assuming I can do that.
我仍然可以做O的线性搜索,或者也可以以这个列表为例,我们先将其进行排序,然后再进行查找,但是在这种情况下,要花费n,log,n的时间去对其进行排序。
On the other hand, if I want to sort it first, OK, if I want to do sort and search, I want to sort it, it's going to take n log n time to sort it, and having done that, then I can search it in log n time.
我先排序,好的,如果我想排序再搜索,我要排序,这需要花n,log,n时间排序,然后做完了,我们能花log,n时间搜索,啊,哪一种更好呢?恩,呵呵。
应用推荐