Bisection methods were known to the ancient Greeks, and it is believed by many, even to the Babylonians.
二分法由古希腊人所发明,我以前也说过,一直到17世纪二分法都被。
I'm going to call it down here with search, which is simply going to call it, and then print an answer out.
然后返回答案,在二分法搜索中,其实有个挺美妙的名称。
Let's search to see though now if a million is in this list, or 10 million, whichever way I did this it must be a million, right?
不管我选哪个,数都挺大的对不对?,用嘴基本的方法,噢,花的时间有点长,好,而用二分法呢?
Done. All right? The basic, that primary search, because it looks at the first element, says it's smaller than everything else, I'm done.
以及其他的元素,检索完成,让我试试二分法呢?,可能会用更长的时间,请注意这里的输出。
Let's pull together what this algorithm actually does. If I generalize binary search, here's what I'm going to stake that this thing does.
总结下二分查找法,下面列举几点它的操作,首先,找中点。
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.
你应该想起来,我们是以一个,叫做二分法求平方根的问题结束的,它运用了二分法去求一个数的平方根,二分法和我们将要花很多时间。
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.
按照二分法的规则来做的,而不是直接得出某种结论,很明显这儿我的目的是什么?,显示这两个相同的东西。
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.
就是当我们处理数字的时候,所称的二分检索,在二分法搜索中,我需要记录区间的开始点和尾点,初始化的时候就是-,问题输入的开始点和尾点,当我开始做测试的时候,我想要做的就是去取中值点。
Now, as I do this, I'm going to use binary search.
现在当我做这项工作的时候,我会用到二分搜索法。
Remember, I said when we do a bisection method, we're assuming the answer lies somewhere between Well, what is the square root of a quarter? It is a half.
记住,我提过当我们用二分法的时候,我们假设答案处于,上边界和下边界之间,0。25的平方根是多少?,是0。5。
Alright. So let's start with the bisection.
好,让我们从二分法开始。
应用推荐