Well, if we actually want to represent something like the number 7, well in binary, not actually in decimal like this.
如果你表达,类似于7的数字,在二进制中,它和十进制可不太一样。
So binary search, the phonebook example, binary search on the pieces of paper on the white board, why is that?
是二分查找,例如电话簿的例子,对其中的某一页进行二分查找,为什么呢?
We started off talking about binary search, and I suggested that this was a log algorithm which it is, which is really kind of nice.
我告诉了你们这是一个对,数级的算法,这是很棒的,我们来一起看看这个算法到底做了什么。
It is a declaration of absolute interdependency among the things that we understand in binary terms but that we take somehow one to be causative of the other when we think about them.
这是在宣布事物之间的绝对的相互性,我们能在二元关系上理解这些事,但是我们惯常于把一个是当成另一个的原因。
Because the two are not identical despite massive amounts of scholarship that confuses this issue: thinks holy means pure, thinks common means impure, and it just doesn't: these are different binary oppositions. The two are not identical.
因为这俩并不完全相同,还是会有很多学者会弄混它们:,认为神圣的就是纯洁的,普通的就是不纯洁的,实则不然:,它们是不同的相对关系,它们并不完全相同。
Happiness is not a binary either-or, zero-one-- either I'm happy or I'm unhappy.
幸福不是二进制的非此即彼,0或-,要么幸福要么不幸福。
So, it makes a binary decision, either I create an action potential or I don't, but that decision could be based on many inputs, not just on input from one cell.
所以 这里产生一个二选一的决策,就是产生动作电位亦或不产生,不过这个决定可能是,根据很多输入信号做出的,而不是仅凭单个细胞所传来的信号
OK. Binary search is perhaps the simplest of the divide and conquer algorithms, and what does that mean? It says, in order to solve a problem, cut it down to a smaller problem and try and solve that one.
好了,二分搜索也许是,最简单的分治算法,这意味着什么?,也就是说,为了解决一个问题,把它切割成小的问题,然后再来一个个解决。
All right? I don't care what's in there, but just assume that's my list. And just to remind you, on your handout, and there it is on the screen, I'm going to bring it back up, there's the little binary search algorithm.
好,我不管列表里是什么,就假定那是一个列表,要提醒你们的是,在你们的讲义上和屏幕上,有一个简单的二分查找算法。
And the third thing I need to decide is how do I combine? You know, point out to you in the binary search case, combination was trivial. The answer to the final search was just the answer all the way up.
第三个问题是我需要决定如何进行合并?,就你们所知的,在二分查找中所打印出来的,合并的过程是非常简单的,最后查询的结果,就是一路上来所以的结果。
OK. At the end of the lecture last time, I also showed you an example of binary search.
好的,在上次课程的最后,我也给你们看了一个二分查找的例子。
The instant unlike binary search, where each instance was separate, here the instances overlap.
这个例子不像搜索二进制数,每个例子是独立的,这里的例子是相互重叠的。
A patterned series of these tiny charged berries on the disk represents a single bit of data in the binary number system used by computers.
这些在磁盘上的有序的小粒子,代表这个当代计算机中,二进制中单独的一位。
This was using something called a bisection method, which is related to something called binary search, which we'll see lots more of later, to find square roots.
你应该想起来,我们是以一个,叫做二分法求平方根的问题结束的,它运用了二分法去求一个数的平方根,二分法和我们将要花很多时间。
Seventy-nine. In fact, if you add up each of these numbers, 9 you should get the decimal number 79 79 from this binary number here.
9,事实上,如果你把这些数字累加,你应该能从这些二进制中9,得到十进制数。
In binary search-- ah, there's that wonderful phrase, this is called a version of binary search just like you saw bin-- or bi-section methods, - when we were doing numerical things- in binary search, I need to keep track of the starting point and the ending point of the list I'm looking at.
就是当我们处理数字的时候,所称的二分检索,在二分法搜索中,我需要记录区间的开始点和尾点,初始化的时候就是-,问题输入的开始点和尾点,当我开始做测试的时候,我想要做的就是去取中值点。
On the other hand, watch what happens with binary. Is the partway one there?
噢,它只比100万的情况下多用了一步,请注意这就是?
So just as a little sanity check, number 15 in binary would be?
再来做个测试,那么二进制中15怎样表达?
If I look in the binary case, takes a little longer.
这里的输出,告诉我们。
Voice and writing, by the way, are not a stable binary.
顺道说一句,声音和文字不是稳定的二元系统。
We're going to call search, which just calls binary search.
我要把它回忆一下,之后我们说的查找算法就是二分查找算法。
OK. So, what do I want you to take away from this? This idea of binary search is going to be a really powerful tool. And it has this property again, of chopping things into pieces.
从这里学到些什么?二分查找的思想,是一个非常有用的工具,我重复一遍,把问题拆成几部分来解决,那事实上,这里的增长率是多少?
Again. Basic premise of binary search, or at least we set it up was, imagine I have a sorted list of elements. We get, in a second, to how we're going to get them sorted, and I want to know, is a particular element in that list..
好,二分查找的基本前提,或者是我们建立二分查找的基础,我们已经有了一个排好序的元素列表,我们就需要知道如何来快速的排序,如何从列表中找到特定的元素。
Now, one of the questions we could still ask is, right, we've got binary search, which has got this nice log behavior.
目前,还有一个问题我们仍然要问的是,对,我们已经学了二分查找,有着非常好的log级别的行为。
I'm narrowing it down. It's getting a little silly but you know I'm going to really be persistent and just follow the rules here of binary search, rather than jumping to conclusions.
按照二分法的规则来做的,而不是直接得出某种结论,很明显这儿我的目的是什么?,显示这两个相同的东西。
But at the end of the day, and here's why we just went with binary and not decimal years ago, when you have one implement a computer with a physical device, it's actually really easy to represent the notion of on or off.
但是最终,之前我们采用二进制,而不是十进制,主要是因为当我们用一台实体机器运行计算机时,这实际上很容易用开或者关的概念来表示。
And it's called divide and conquer for the obvious reason. I'm going to divide it up into sub-problems with the hope that those sub-problems get easier. It's going to be easier to conquer if you like, and then I'm going to merge them back. Now, in the binary search case, in some sense, this is a little bit trivial.
因此被称为分治的原因就这么简单,将一个问题分解成一些子问题,并希望这些子问题解决起来比较方便,正如你希望的,求解的过程也会变得简单,下面就是把结果合并起来,现在,在二分搜索的例子里,从某些方面来说,这有点微不足道。
Right, in the binary case, bam.
所花费的步骤数是一样的。
OK. That's the basic idea of binary search.
好了,这就是二分查找的基本思想。
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?
我们将要调用这个二分查找,它将会在列表里面搜索元素,假定这里是,列表的第一个元素,那里是列表的最后一个元素,代码内部到底做了什么?
应用推荐